suggest(prefix, options)

Suggests search terms that start with the provided prefix.

// ["hamburger", "hammer", "hamper", "hamster", "hamburg"]

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.


  • 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.


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


  • ArgumentError if an invalid option has been provided.


List suggestions that start with sc:

// ["scrivito", "science", "screen"]

Limit suggestions to specific attributes:

Scrivito.Obj.all().suggest('ham', { attributes: ['title'] })
// ["hammer"]

Limit the number of suggestions to 10:

Scrivito.Obj.all().suggest('sc', { limit: 10 });
// ["scrivito", "science"]

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

Scrivito.Obj.where('language', 'equals', 'de').suggest('Kin');
// ["kindergarten", "kind", "kinder"]

Boost suggestions in “Product” objects:

Scrivito.Obj.all().boost('_objClass', 'equals', 'Product', 10).suggest('Ham');
// ["hammer", "hamburger", "hamper", "hamster"]