Developing the Search API Autocomplete module integration
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:
- Edit
composer.json, and add"drupal/search_api_autocomplete": "^1"to the"require-dev"section.- The jq utility is used in The short version above to automate this step.
- This step is currently needed to work around a limitation in version
1.0.0-rc21of DDEV's ddev/ddev-drupal-contrib add-on.
- Run
ddev poserto install Search API Autocomplete. - 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
- Log in, if you are not already (i.e.:
ddev drush -y uli). - Go to
/admin/config/search/search-api/index/test_elasticsearch_index/autocomplete
Check the checkbox in thetest_elasticsearch_index_searchrow, then clickSave.
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.
- Go to
/test-elasticsearch-index-search - In the Fulltext search textfield, start typing
foo: after the 3rd letter, you start seeing suggestions (i.e.:foo baz,foo test foobuz, etc.) - Click the
foo test foobuzsuggestion. 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
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion