setRemoveStopWords method

AlgoliaQuery setRemoveStopWords(
  1. dynamic value
)

RemoveStopWords

Removes stop (common) words from the query before executing it

Stop word removal is useful when you have a query in natural language, e.g. “what is a record?”. In that case, the engine will remove “what”, “is”, and “a” before executing the query, and therefore just search for “record”. This will remove false positives caused by stop words, especially when combined with optional words (see optionalWords and removeWordsIfNoResults).

Usage notes

  • removeStopWords is used in conjunction with the queryLanguages setting.

  • You can send removeStopWords one of 3 values:

    • true, which enables the stop word functionality, ensuring that stop words are removed from consideration in a search. The languages supported here are either every language (this is the default, see list of languages below), or those set by queryLanguages. See queryLanguages example below.
    • false, which disables stop word functionality, allowing stop words to be taken into account in a search.
    • a list of language ISO codes for which stop words should be enabled. This list will override any values that you may have set in ‘queryLanguages`.
  • For most use cases, however, it is better not to use this feature, as people tend to search by keywords on search engines (that is, they naturally omit stop words).

  • Prefix logic: Stop words only apply on query words that are not interpreted as prefixes. To control how prefixes are interpreted, check out queryType.

  • List of supported languages with their associated language ISO code:

    Afrikaans=af Arabic=ar Azerbaijani=az Bulgarian=bg Bengali=bn Catalan=ca Czech=cs Welsh=cy Danish=da German=de Greek=el English=en Esperanto=eo Spanish=es Estonian=et Basque=eu Persian (Farsi)=fa Finnish=fi Faroese=fo French=fr Irish=ga Galician=gl Hebrew=he Hindi=hi Hungarian=hu Armenian=hy Indonesian=id Icelandic=is Italian=it Japanese=ja Georgian=ka Kazakh=kk Korean=ko Kurdish=ku Kirghiz=ky Lithuanian=lt Latvian=lv Maori=mi Mongolian=mn Marathi=mr Malay=ms Maltese=mt Norwegian Bokmål=nb Dutch=nl Norwegian=no Northern Sotho=ns Polish=pl Pashto=ps Portuguese=pt Brazilian=pt-br Quechua=qu Romanian=ro Russian=ru Slovak=sk Albanian=sq Swedish=sv Swahili=sw Tamil=ta Telugu=te Thai=th Tagalog=tl Tswana=tn Turkish=tr Tatar=tt Ukranian=uk Urdu=ur Uzbek=uz Chinese=zh

Source: Learn more

Implementation

AlgoliaQuery setRemoveStopWords(dynamic value) {
  assert(value != null, 'value can not be empty');
  assert(!_parameters.containsKey('removeStopWords'),
      '[removeStopWords] can not be called multiple times.');
  assert(((value is bool) || (value is List<String>)),
      'value must be true|false|["language ISO code", ...]; but value found was `${value.runtimeType}`');
  return _copyWithParameters(<String, dynamic>{'removeStopWords': value});
}