You are here

README.txt in Search API Autocomplete 8

Same filename and directory in other branches
  1. 7 README.txt
Search API Autocomplete
-----------------------

Adds autocomplete capabilities for Search API searches.


Information for users
---------------------

- Necessary server feature

The default "Retrieve from server" suggester provided by this module retrieves
autocomplete suggestions from the server, based on the indexed data. For this to
work, the server has to support the "search_api_autocomplete" feature. Having
autocompletion for indexes on servers for which the backend doesn't support this
feature is only possible if you use a different suggester (like "Display live
results", or one provided by a separate module).
Currently, the Solr backend [1] and the Database backend (included in the Search
API project) are known to support this feature.

[1] https://www.drupal.org/project/search_api_solr

- Necessary setup

After having installed and enabled the module, you have to do some
administrative steps to activate the autocomplete functionality. Autocompletion
can be enabled and configured for each search separately.

To activate autocompletion for an index's searches, go to the index's
„Autocomplete“ tab. There, you see all available searches for the index and can
enable (and afterwards configure) autocompletion for each of them. All fulltext
key fields on the searches should then become autocompletion fields.

There is an autocomplete permission for each separate search. Therefore, after
adding autocomplete to a new search, don't forget to set the appropriate
permissions.

- Supported searches

Currently, only search forms built by the Search API Pages or Views modules are
supported directly. However, other modules can easily also use this
functionality. See the "Information for developers" below for details.

- Hidden settings

search_api_autocomplete.settings:enable_custom_scripts:
  Enables the "Use custom script" suggester which lets you redirect the
  autocomplete AJAX request to a path or URL of your choosing. Since this is
  mostly interesting for developers, who want to write their own autocomplete
  code (possibly bypassing Drupal for performance reasons), this suggester is
  not available otherwise by default. (Setting defaults to FALSE, set to TRUE to
  make the suggester available.)


Information for developers
--------------------------

- Supporting a new method of creating suggestions

You can add your own implementation for creating autocomplete suggestions by
creating a so-called "suggester" plugin. For details, see the interface
documentation in src/Suggester/SuggesterPluginBase.php.

- Supporting autocompletion with a backend plugin

To support autocompletion with a backend plugin, the plugin has to support the
"search_api_autocomplete" feature. This will necessitate the backend class to
have a getAutocompleteSuggestions() method as detailed in the interface in
src/AutocompleteBackendInterface.php.

- Supporting autocompletion on a search form

If you have a search form not generated by the Search views or Search pages
modules, you can add an autocomplete search plugin to support autocompletion for
it. See src/Search/SearchPluginBase.php for the plugin type documentation,
or src/Plugin/search_api_autocomplete/search/ for examples. Additionally, you
will need to write a form alter hook to adapt your search form's input element.
For examples, see search_api_autocomplete_form_views_exposed_form_alter() or
search_api_autocomplete_form_search_api_page_block_form_alter().

File

README.txt
View source
  1. Search API Autocomplete
  2. -----------------------
  3. Adds autocomplete capabilities for Search API searches.
  4. Information for users
  5. ---------------------
  6. - Necessary server feature
  7. The default "Retrieve from server" suggester provided by this module retrieves
  8. autocomplete suggestions from the server, based on the indexed data. For this to
  9. work, the server has to support the "search_api_autocomplete" feature. Having
  10. autocompletion for indexes on servers for which the backend doesn't support this
  11. feature is only possible if you use a different suggester (like "Display live
  12. results", or one provided by a separate module).
  13. Currently, the Solr backend [1] and the Database backend (included in the Search
  14. API project) are known to support this feature.
  15. [1] https://www.drupal.org/project/search_api_solr
  16. - Necessary setup
  17. After having installed and enabled the module, you have to do some
  18. administrative steps to activate the autocomplete functionality. Autocompletion
  19. can be enabled and configured for each search separately.
  20. To activate autocompletion for an index's searches, go to the index's
  21. „Autocomplete“ tab. There, you see all available searches for the index and can
  22. enable (and afterwards configure) autocompletion for each of them. All fulltext
  23. key fields on the searches should then become autocompletion fields.
  24. There is an autocomplete permission for each separate search. Therefore, after
  25. adding autocomplete to a new search, don't forget to set the appropriate
  26. permissions.
  27. - Supported searches
  28. Currently, only search forms built by the Search API Pages or Views modules are
  29. supported directly. However, other modules can easily also use this
  30. functionality. See the "Information for developers" below for details.
  31. - Hidden settings
  32. search_api_autocomplete.settings:enable_custom_scripts:
  33. Enables the "Use custom script" suggester which lets you redirect the
  34. autocomplete AJAX request to a path or URL of your choosing. Since this is
  35. mostly interesting for developers, who want to write their own autocomplete
  36. code (possibly bypassing Drupal for performance reasons), this suggester is
  37. not available otherwise by default. (Setting defaults to FALSE, set to TRUE to
  38. make the suggester available.)
  39. Information for developers
  40. --------------------------
  41. - Supporting a new method of creating suggestions
  42. You can add your own implementation for creating autocomplete suggestions by
  43. creating a so-called "suggester" plugin. For details, see the interface
  44. documentation in src/Suggester/SuggesterPluginBase.php.
  45. - Supporting autocompletion with a backend plugin
  46. To support autocompletion with a backend plugin, the plugin has to support the
  47. "search_api_autocomplete" feature. This will necessitate the backend class to
  48. have a getAutocompleteSuggestions() method as detailed in the interface in
  49. src/AutocompleteBackendInterface.php.
  50. - Supporting autocompletion on a search form
  51. If you have a search form not generated by the Search views or Search pages
  52. modules, you can add an autocomplete search plugin to support autocompletion for
  53. it. See src/Search/SearchPluginBase.php for the plugin type documentation,
  54. or src/Plugin/search_api_autocomplete/search/ for examples. Additionally, you
  55. will need to write a form alter hook to adapt your search form's input element.
  56. For examples, see search_api_autocomplete_form_views_exposed_form_alter() or
  57. search_api_autocomplete_form_search_api_page_block_form_alter().