removeStopWords

scope settings search
type boolean | array of strings
default false
description

Remove stop words from the query before executing it.

This parameter may be:

  • a boolean: enable or disable stop words for all supported languages; or
  • a list of language ISO codes for which stop word removal should be enabled.

In most use-cases, we don’t recommend enabling stop word removal.

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). For most use cases, however, it is better not to use this feature, as people tend to search by keywords on search engines (i.e. they naturally omit stop words).

Stop words removal is only applied on query words that are not interpreted as prefixes.

As a consequence, the behavior of removeStopWords also depends on the queryType parameter:

  • queryType=prefixLast means the last query word is a prefix and won’t be considered for stop word removal;
  • queryType=prefixNone means no query word is a prefix, therefore stop word removal will be applied to all query words;
  • queryType=prefixAll means all query words are prefixes, therefore no stop words will be removed.

List of supported languages with their associated ISO code:

Arabic=ar, Armenian=hy, Basque=eu, Bengali=bn, Brazilian=pt-br, Bulgarian=bg, Catalan=ca, Chinese=zh, Czech=cs, Danish=da, Dutch=nl, English=en, Finnish=fi, French=fr, Galician=gl, German=de, Greek=el, Hindi=hi, Hungarian=hu, Indonesian=id, Irish=ga, Italian=it, Japanese=ja, Korean=ko, Kurdish=ku, Latvian=lv, Lithuanian=lt, Marathi=mr, Norwegian=no, Persian (Farsi)=fa, Polish=pl, Portugese=pt, Romanian=ro, Russian=ru, Slovak=sk, Spanish=es, Swedish=sv, Thai=th, Turkish=tr, Ukranian=uk, Urdu=ur.

Examples

Remove stop words for some languages by default

<?php
$index->setSettings([
  'removeStopWords' => ['en', 'fr']
]);
index.set_settings({
  removeStopWords: ['en', 'fr']
})
index.setSettings({
  removeStopWords: ['en', 'fr']
});
index.set_settings({
    'removeStopWords': ['en', 'fr']
})
index.setSettings([
    "removeStopWords": ["en", "fr"]
])
index.setSettings(new JSONObject().put("removeStopWords", "en, fr"));
index.SetSettings(
  JObject.Parse(@"{""removeStopWords"":[""en"",""fr""]}")
);
index.setSettings(
  new IndexSettings().setRemoveStopWords(RemoveStopWords.of(Arrays.asList("en", "fr")))
);
res, err := index.SetSettings(algoliasearch.Map{
    "removeStopWords": []string{
        "en",
        "fr",
    },
})
client.execute {
  changeSettings of "myIndex" `with` IndexSettings(
    removeStopWords = Some(RemoveStopWords.list(Seq("en", "fr"))
  )
}
<?php
$results = $index->search('query', [
  'removeStopWords' => ['en', 'fr']
]);
results = index.search('query', {
  removeStopWords: ['en', 'fr']
})
index.search({
  query: 'query',
  removeStopWords: ['en', 'fr']
}).then(res => {
  // console.log(res);
});
results = index.search('query', {
    'removeStopWords': ['en', 'fr']
})
let query = Query(query: "query")
query.removeStopWords = .selected(["en", "fr"])

index.search(query, completionHandler: { (res, error) in
    print(res)
})
index.search(new Query("query").setRemoveStopWords("en, fr"));
index.search(
  new Query("query").EnableRemoveStopWords(new EnabledRemoveStopWordsList { Enabled = "en,fr"})
);
index.search(
  new Query("query").setRemoveStopWords(RemoveStopWords.of(Arrays.asList(
    "en",
    "fr"
  )))
);
res, err := index.Search(query, algoliasearch.Map{
    "removeStopWords": []string{
        "en",
        "fr",
    },
})
client.execute {
  search into "myIndex" query Query(
    query = Some("query"),
    removeStopWords = Some(RemoveStopWords.list(Seq("en", "fr")))
  )
}

Remove stop words for all languages by default

<?php
$index->setSettings([
  'removeStopWords' => true
]);
index.set_settings({
  removeStopWords: true
})
index.setSettings({
  removeStopWords: true
});
index.set_settings({
    'removeStopWords': True
})
index.setSettings([
    "removeStopWords": true
])
index.setSettings(new JSONObject().put("removeStopWords", true));
index.SetSettings(
  JObject.Parse(@"{""removeStopWords"":""true""}")
);
index.setSettings(
  new IndexSettings().setRemoveStopWords(RemoveStopWords.of(true))
);
res, err := index.SetSettings(algoliasearch.Map{
    "removeStopWords": true,
})
client.execute {
  changeSettings of "myIndex" `with` IndexSettings(
    removeStopWords = Some(RemoveStopWords.`true`)
  )
}
<?php
$results = $index->search('query', [
  'removeStopWords' => true
]);
results = index.search('query', {
  removeStopWords: true
})
index.search({
  query: 'query',
  removeStopWords: true
}).then(res => {
  // console.log(res);
});
results = index.search('query', {
    'removeStopWords': True
})
let query = Query(query: "query")
query.removeStopWords = .all(true)

index.search(query, completionHandler: { (res, error) in
    print(res)
})
index.search(new Query("query").setRemoveStopWords(true));
index.search(
  new Query("query").EnableRemoveStopWords(new EnabledRemoveStopWordsBool { Enabled = true })
);
index.search(
  new Query(query).setRemoveStopWords(RemoveStopWords.of(true))
);
res, err := index.Search(query, algoliasearch.Map{
    "removeStopWords": true,
})
client.execute {
  search into "myIndex" query Query(
    query = Some("query"),
    removeStopWords = Some(RemoveStopWords.`true`)
  )
}
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala