Configuring autocomplete
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.
Training your autocomplete model
Inputs to train your autocomplete model can come from fields in your records and user queries.
Training autocomplete from fields
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-v2
step 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 5
which is configured by the maxWords
parameter.
The train-autocomplete-v2
step will also train the phrases for your spelling model unless you have defined phrase training in the train-spelling
step
Training autocomplete from user queries
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-autocomplete
step 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
minResults
The best result had an index score of 1.0. Configured by
minIndexScore
The query contains at most 5 words. Configured by
maxWords
Changing training configuration
Changes to the train-autocomplete-v2
and train-autocomplete
steps are only effective for future training. All past training will be based on the configuration at the time of training.
Training from other sources
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..
Querying your autocomplete model
To enable autocomplete when querying, add the autocomplete
step 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-search
step in the pipeline that uses the autocomplete
step.
The following example performs autocomplete in the input query q
, setting the query suggestions to q.suggestions
and skips a search.
The order in which query suggestions are returned can be influenced by setting const:labelWeights
. The labels are assigned in the train-autocomplete-v2
step. 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 brand
and category
.
Last updated