Adding processors
Search API Processors modify:
- the data going into the index (i.e.: documents being indexed),
- the search query before it is sent, and,
- the search results when they are returned.
Processors are set on the Search API Index, and we recommend using them to improve the search user-experience.
For more information about processors, see the Processors section in the Search API documentation on Adding an index, and the Search API documentation on Processors.
Start from Search API's configuration at /admin/config/search/search-api, find the table row for an Index, click the Dropbutton's progressive disclosure arrow, then click Processors. Or, click Edit in an Index's table row, then click the Processors tab at the top.
Enabled [processors]
The first section of the Manage processors for search index page shows a fieldset with the title Enabled, containing a checkbox for each available processor.
Search API defines the Content access, Entity status, Highlight, HTML filter, Ignore case, Ignore characters, Index hierarchy, Number field-based boosting, Reverse entity references, Role-based access, Stemmer, Stopwords, Tokenizer, Transliteration, and Type-specific boosting processors. Please see the Processors included in the Search API module section of the Processors page in the Search API documentation for more information about these processors.
Other Drupal modules can add additional processors — see the documentation for those modules for more information about the processors that they add.
The Elasticsearch Connector module adds the following processor:
- Elasticsearch Highlighter: this integrates with Elasticsearch's Highlighting feature.
We recommend using the Elasticsearch Highlighter processor instead of Search API's built-in Highlight plugin.
We recommend configuring Search API's built-in HTML filter processor on Drupal's Formatted text fields (i.e.: fields that may contain HTML).
Search API has several processors that are designed to prevent accidental information disclosure. (For example, to prevent unpublished content, or content that the current user doesn't have access to from showing up in search results).
At time-of-writing, these processors are:
- the Content access processor,
- the Entity status processor,
- the Role-based access processor.
Take the time to:
- learn what kinds of information should and should not be disclosed for your site;
- learn how these processors work,
- configure them properly, and,
- test your configuration thoroughly.
Processor order
The second section of the Manage processors for search index page has some controls to change the order that Processors are run.
The Preprocess index section affects the order that processors run on data when it is about to be added to the index (although this has no effect if your index is Read-only). These often affect what data gets indexed.
The Preprocess query section affects the order that processors run on a search query before it gets sent to Elasticsearch. These often modify the search query, and/or set boosts.
The Postprocess query section affects the order that processors run on search results returned by Elasticsearch. These often filter search results.
Most of the time, the author of this page has found that the default order is fine — but double-check the order if you enable a processor that states that it needs to run before/after other processors.
Not every enabled processor shows up in the Processor order section: the author of this page is uncertain if this is a bug or not.
Processor settings
The third section of the Manage processors for search index page has settings for processors that have them.
Please refer to the Search API documentation for how to configure its processors. If you've installed a module that adds its own processors, please refer to that module's documentation for how to configure its settings.
Configuring the Elasticsearch Highlighter processor
The Elasticsearch Connector module includes a processor, Elasticsearch Highlighter, to let Drupal leverage Elasticsearch's Highlighting feature. For the most part, the settings for this processor mirror Elasticsearch's Highlighter settings.
- Fields to highlight: Select which fields that you configured for the index to generate highlights from.
- Highlighter type: Select which Elasticsearch highlighter algorithm to use. Note that the Elasticsearch Connector module doesn't currently support the
fvhhighlighter algorithm. - Fragmenter: If you set Highlighter type to
Plain, the Fragmenter determines whether nearby snippets get joined together or not. - Boundary scanner: If you set Highlighter type to
Unified, the Boundary scanner determines where the text in the Fields to highlight are split to make snippets. - Bounder scanner locale: If you set Highlighter type to
Unifiedand Boundary scanner locale toSentence, then Boundary scanner locale lets you set which Elasticsearch language analyzers are used to determine where a sentence begins and ends. - Highlight opening tag: This lets you configure the HTML tag that surrounds highlighted text. Elasticsearch Connector will automatically determine the highlight closing tag based on what you set here.
- Snippet encoder: ElasticSearch doesn't natively provide a way to remove HTML tags, only escape them. The ElasticSearch Connector module's post-processor strips out any HTML tags that are not the highlighting tag to avoid invalid HTML in snippets, so No encoding is safe to use and usually produces the results you would expect.
- Maximum number of snippets per field: The maximum number of snippets to return for each selected Field to highlight.
- Snippet size: The approximate number of characters that should be in a snippet.
- Snippet size when there is no match: If ElasticSearch finds a match in a field that is not selected for highlighting, it can return a snippet from the beginning of the field(s) that are selected for highlighting instead, so that there's something to display.
- Snippet order: You can either order snippets by relevance, or order them by the order they appear in the text in the field.
- Only show snippets from fields that match the query: This corresponds with Elasticsearch's
require_field_matchconfiguration. - Snippet-joiner: Enter text that you want to put between snippets in the highlighting field. Elasticsearch Connector combines all the snippets into a single string, and the text you enter in this field is displayed between each snippet.
Next steps
Click the Save button at the bottom of the page to save your settings.
Continue with Indexing your content.
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