suggest(prefix, options)

Suggests search terms that start with the provided prefix.

suggest works case insensitive, and all results are converted to lower case.

Preceding calls to and or andNot may limit the amount of documents that are searched for suggestions.

Preceding calls to boost may adjust the ranking of the documents from which suggestions are taken.

Params

  • prefix (String) – The prefix string for which suggestions should be determined.
  • options (optional) (Object)
    • limit (number) – The maximum number of suggestions to return. Defaults to 5. Maximum: 100.
    • attributes (Array<String>) – The list of attributes that serve as input for suggestions. The special value ["*"], which is the default, causes all html, string and stringlist attributes to be taken account of.

Returns

Array<String> – A list of words the user could search for.

Throws

  • ArgumentError if an invalid option has been provided.

Examples

List suggestions that start with sc:

Limit suggestions to specific attributes:

Limit the number of suggestions to 10:

Limit suggestions for the prefix Kin to objects for which the “de” language flag is set:

Boost suggestions in “Product” objects: