Learn how to configure and customise autocomplete for search.
There are two aspects to configuring autocomplete functionality in Search.io:
- Training your autocomplete model.
- Querying your autocomplete model to get autocomplete suggestions.
Autocomplete training is automatic for website and API collections. Training is performed from metadata in your records and from user queries (please refer to the sections below for more detail). A query pipeline called autocomplete is automatically created which will be used for your application when it is in autocomplete mode.
Inputs to train your autocomplete model can come from fields in your records and user queries.
Common fields used for autocomplete training include:
- Crawler (Website) collections: headings, titles, or other meta fields in your webpages.
- API collections (e.g. example e-commerce): brand, product name, category and other fields in your product data.
Be selective in the fields you use for autocomplete training to generate the best possible suggestions. Typically short, descriptive fields are best. See our Phrase training guide for more information
The training is done via the
train-autocomplete-v2step in your record pipeline. This trains your autocomplete model when record are first created. In the example below a field value will enter the autocomplete model if its word count does not exceed
5which is configured by the
- id: train-autocomplete-v2
train-autocomplete-v2step will also train the phrases for your spelling model unless you have defined phrase training in the
User queries typed into your search box can be used as a training source for your autocomplete model. This allows autocomplete to instantly adapt to trending or popular queries.
You can customize criteria that determine whether a user query should be used for autocomplete training via the
train-autocompletestep in the query pipeline
The possible criteria include:
- Does the query return a minimum number of search results? For example, you probably do not want to train queries that lead to no search results.
- Does the top result for the query meet a minimum score or index score? We recommended setting a minimum score or index score as an indicator of whether the query will yield relevant results.
- Is the query word length less than a maximum word length? It is recommended to set a maximum word limit otherwise your autocomplete model may include nonsensical suggestions.
A users search query will enter the autocomplete model if the following criteria is met:
- All of the words from the users query already exist in your autocomplete model. This safeguard ensures no new and potentially damaging words can enter the model
- The query lead to at least 1 result. Configured by
- The best result had an index score of 1.0. Configured by
- The query contains at most 5 words. Configured by
- id: train-autocomplete
Changes to the
train-autocompletesteps are only effective for future training. All past training will be based on the configuration at the time of training.
It is possible to train your autocomplete model from other data sources like your query history from another system. Please get in touch for more details..
To enable autocomplete when querying, add the
autocompletestep in the query pipeline. Using this step, you can configure how training sources are weighted when returning the order of autocomplete suggestions. For example, you may want to weight phrases from user queries to be more important than a field in your collection.
Normally, you do not want to be returning autocomplete suggestions and performing a search at the same time. It is typical to add the
skip-searchstep in the pipeline that uses the
The following example performs autocomplete in the input query
q, setting the query suggestions to
q.suggestionsand skips a search.
description: Autocomplete specific pipeline
- id: autocomplete
- id: skip-search
The order in which query suggestions are returned can be influenced by setting
const:labelWeights. The labels are assigned in the
train-autocomplete-v2step. If empty, all labels are weighted equally.
The following example sets live query training (denoted by the label
query) to be twice as important as the record fields
- id: autocomplete
- value: "query:1.0,brand:0.5,category:0.5"