🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API Reference / API Parameters / naturalLanguages
Type: list of strings
Engine default: []
Parameter syntax
'naturalLanguages' => ['language ISO code', ...]

Can be used in these methods:

About this parameter

Change the default of parameters for handling natural language searches as opposed to keyword searches, for example, for voice search.

The naturalLanguages parameter changes the following parameters and setttings:

Usage notes

  • For optimal relevance, we recommend to only pass languages that occur in your data.

  • 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

Examples

Set Natural Languages

In this example, we set French (fr) as the natural language.

At query time, ignorePlurals and removeStopWords are set to fr, and removeWordsIfNoResults is set to allOptional.

1
2
3
$index->search('', [
  'naturalLanguages' => ['fr']
]);

Override naturalLanguages with query parameters

In this example, we set French (fr) as a natural language, and we override removeWordsIfNoResults to firstWords.

At query time, both ignorePlurals and removeStopWords are set to fr, and removeWordsIfNoResults is set to firstWords because we explicitly pass it as a query parameter.

1
2
3
4
$index->search('', [
  'naturalLanguages' => ['fr'],
  'removeWordsIfNoResults' =>'firstWords'
]);
Did you find this page helpful?