4 min read

Fallback features

Fallback features are search options used in the event the search engine does not retrieve any results for the query. Empathy Platform offers these fallback features:

  • Spell Check: Performs a spell check on the original no-results query to find valid queries with results.
  • Partial Results: Splits the original query into smaller queries to return those queries with results.

interact

For an explanation on how to set up the features in the Search microservice, see Feature configuration.

Spell Check

The Spell Check (spellcheck) fallback feature lets you perform a spell check on the query using the search engine. When configured, spell check is automatically run after a query with no results is executed. In this scenario, a list of suggestions for the spell-checked query is obtained from Elasticsearch and the first one is selected.

After this, the whole chain of processors is run again using the spell-checked query. A spell-checked field containing the spell-checked query is included in the response.

danger

This fallback feature requires the matchSearch and multiMatchSearch search type features due to how the suggestions are retrieved. It is incompatible with other search type features.

Search configuration

Since Spell check is a fallback feature, it must be configured in the fallback section of the configuration.

Config parameters

Field Description Type Default value
mainCollectionId Collection name used to compose the name of the index to search on (required) String ---
secondaryCollectionId Secondary collection name used to compose the name of the index to search on (required) String ---
collectionType Collection type. Available types: CATALOG, EMPATHIZE, BOOSTS, QUERYSIGNALS or LINKS (required) String ---
enablePhraseSuggester Enables the phrase suggester (opens new window) when performing a spell check on the query. If set to false, a term suggester (opens new window) is used (required) Boolean ---
redisTTL Time to live for the data in Redis cache, in seconds (optional) Integer ---
redisCached Enables the Redis cache (optional) Boolean ---

Important

  • If you want to use the Spell Check feature, you must set up all fields that can be spell-checked with a copyTo to a "spell-checked" field in the index mapping.

  • If you want to use the Elasticsearch phrase suggester (opens new window) feature, you need to define a shingle configuration in the settings of the index.

Configuration example

{
  "name": "spellcheck",
  "config": {
    "collectionType": "CATALOG",
    "mainCollectionId": "collection",
    "secondaryCollectionId": "secondaryCollection",
    "enablePhraseSuggester": true,
    "redisCached": true,
    "redisTTL": 1200
  }
}

Partial Results

The Partial Results (partials) fallback feature lets you split the original query into smaller queries, search for results using those partial queries, and return them into the main response. This way, shoppers are offered similar queries that might have results.

When configured, Partial Results is automatically run after a query is performed with no results. In this scenario, a list of partial queries is generated, and a query to Elasticsearch is run to retrieve results for each of them. After this, the partial queries with the response are added to the main result. The order of the partial results returned is: partial queries with the highest number of terms and then partial queries with more results.

danger

This fallback feature requires the multiMatchSearch search type feature due to how the query to Elasticsearch is formed to retrieve results for partial results. It is incompatible with other search type features.

Search configuration

Since Partial Results is a fallback feature, it must be configured in the fallback section of the configuration.

Config parameters

Field Description Type Default value
mainCollectionId Collection name used to compose the name of the index to search on (required) String ---
secondaryCollectionId Secondary collection name used to compose the name of the index to search on (optional) String ---
collectionType Collection type. Available types are: CATALOG, EMPATHIZE, BOOSTS, QUERYSIGNALS or LINKS (required) String ---
redisTTL Time to live for the data in Redis cache, in seconds (optional) Integer ---
redisCached Enables the Redis cache (optional) Boolean ---
returnableFields Fields to return in the response content of each partial result (required) Array ---
maxNumberOfPartials Maximum number of partial queries to be returned (optional) Integer 2
maxNumberOfDocsPerPartial Maximum number of documents to be returned for each partial query. If you set to 0, no documents are returned (optional) Integer 5
minTermLength Minimum length that a term must have to be partial query candidate (optional) Integer 0
maxTermsPerPartial Maximum number of terms that a partial query must have (optional) Integer 4
{
  "name": "partials",
  "config": {
    "collectionType": "CATALOG",
    "mainCollectionId": "collection",
    "secondaryCollectionId": "secondaryCollection",
    "redisCached": true,
    "redisTTL": 1200,
    "returnableFields": [
      "field1",
      "field2"
    ],
    "maxNumberOfPartials": 3,
    "maxNumberOfDocsPerPartial": 4,
    "minTermLength": 0,
    "maxTermsPerPartial": 3
  }
}