How to display autocomplete suggestions

Article: dts0232

Applies to: dtSearch Engine 7.60 and later

The WordListBuilder API object provides multiple options for generating autocomplete suggestions as a user is entering a search request:

WordListBuilder.ListWords will list a specified number of words before and after the word the user is typing, This can be used to display a scrolling word list, similar to what appears in the Search dialog box in dtSearch Desktop.

WordListBuilder.ListMatchingWords lists all words that match a word.  You can use this to generate suggestions based on words that start with the same letters, or, to offer "did you mean" suggestions, you can use fuzzy searching to generate a list of words similar to the word entered.

WordListBuilder.ListFieldValues lists values from a particular field, if that field was designated as an enumerable field during indexing.  This can be used to generate autocomplete suggestions limited to a particular field.

WordListBuilder also supports generating suggestions based on a subset of the documents in an index.  You can use a SearchFilter object to specify a subset of an index, and then use ListMatchingWords or ListFieldValues to get terms to use for auto-complete that will be limited to the terms that are present in the subset.  Use WordListBuilder.SetFilter to attach the SearchFilter to the WordListBuilder.

Related articles

Faceted Search
https://support.dtsearch.com/faq/dts0222.htm

Limiting searches with SearchFilters
https://support.dtsearch.com/webhelp/dtsearchCppApi/Limiting_searches_with_SearchFilters.html