naturalLanguages
[]
'naturalLanguages' => ['language ISO code', ...]
Can be used in these methods:
search,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
browse,
searchForFacetValues,
generateSecuredApiKey,
addAPIKey,
updateAPIKey
search,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
searchAsync,
browseAsync,
searchForFacetValues
Search,
Browse,
SearchForFacetValues,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
browse,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
BrowseObjects,
SearchForFacetValues,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
browse index,
search into facet values,
generateSecuredApiKey,
add key,
update key
About this parameter
This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as
ignorePlurals
, removeStopWords
,
removeWordsIfNoResults
, analyticsTags
and ruleContexts
. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search.
The naturalLanguages
parameter changes the following parameters and setttings:
removeStopWords
andignorePlurals
are set to the given list of languages.removeWordsIfNoResults
is setallOptional
.- It adds the
natural_language
value toruleContexts
. - It adds the
natural_language
value toanalyticsTags
.
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'
]);