HomeDev guideAPI ReferenceGraphQL
Dev guideUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Autocomplete selection

Select autocomplete field

πŸ‘

Beta

The Optimizely Graph .NET Client is in beta. Contact your Customer Success Manager for information.

Autocomplete, word completion, type-ahead, or search-as-you-type, predicts the rest of a word a user is typing.

The Autocomplete method will build an autocomplete request for the typed query. The method needs to specify the field and use the AutoCompleteOperators instance for filtering and limiting the result. Currently, Optimizely only supports the field with the type String or IEnumerable<string>.

The following example gets the suggestion with filter value β€œshoe” and gets the ten most relevant results:

var autocompleteOperator = 
 new AutoCompleteOperators()
.Value(β€œshoe”) //mandatory
.Limit(10); //optional

var query = queryBuilder
.ForType<MyDocumentType>()
  .Autocomplete(x=>x.Property, autocompleteOperator)
.ToQuery()
.BuildQueries();

The Value method is mandatory for an autocomplete query, and the result will be based on the value of the parameter:

  • Can be one or more words and in the same word order.
  • Each word can be a maximum of ten characters, when longer, no suggestions are returned.
  • If the value consists of only an empty string, then no autocomplete suggestions are retrieved.
  • Punctuation characters will be ignored when matching.
  • HTML tags will not match with results.

Limit_ is optional for limiting the results. The default value is 10, and the max value is 1,000.