Developing the Search API Autocomplete module integration

Last updated on
9 January 2025

The Search API Autocomplete module provides autocomplete functionality for Search API searches. This feature is sometimes known as Search-As-You-Type.

This page is a testing guide, intended for people who want develop the Elasticsearch Connector module, so the instructions below assume that you have already set up an Elasticsearch Connector local development environment, and do not reflect best practices for a production environment!

Setup

Begin by following the instructions in the Set up a local environment documentation. Next...

The short version: the following commands were last tested on 2024-12-30 to download and install a version of Search API Autocomplete in the 8.x-1.x release series...

cat composer.json | jq --indent 4 '. * {"require-dev": {"drupal/search_api_autocomplete": "^1"}}' | tee composer.json
ddev poser
ddev drush -y pm:install search_api_autocomplete

... next, follow the instructions in the Configure the module for testing section below.

The expanded version:

  1. Edit composer.json, and add "drupal/search_api_autocomplete": "^1" to the "require-dev" section.
  2. Run ddev poser to install Search API Autocomplete.
  3. Enable the Search API Autocomplete module and its dependencies.

... next, follow the instructions in the Configure the module for testing section below.

Configure the module for testing

  1. Log in, if you are not already (i.e.: ddev drush -y uli).
  2. Go to /admin/config/search/search-api/index/test_elasticsearch_index/autocomplete
    Check the checkbox in the test_elasticsearch_index_search row, then click Save.

Test case

Note that the test case below assumes that the test content from the test module search_api_test_example_content has been imported.

  1. Go to /test-elasticsearch-index-search
  2. In the Fulltext search textfield, start typing foo: after the 3rd letter, you start seeing suggestions (i.e.: foo baz, foo test foobuz, etc.)
  3. Click the foo test foobuz suggestion. You are taken to /entity_test_mulrev_changed/manage/2

Making changes to Elasticsearch Connector

The Setup instructions above make changes to Elasticseach Connector's composer.json file because of a limitation in DDEV's ddev/ddev-drupal-contrib add-on: please do not commit these changes to composer.json when submitting a patch or merge request.

Help improve this page

Page status: No known problems

You can: