queryLanguages
[]
'queryLanguages' => ['language ISO code', ...]
Can be used in these methods:
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browse,
searchForFacetValues,
generateSecuredApiKey,
addAPIKey,
updateAPIKey
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
searchAsync,
setSettingsAsync,
browseAsync,
searchForFacetValues
Search,
SetSettings,
Browse,
SearchForFacetValues,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
setSettings,
browse,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
BrowseObjects,
SearchForFacetValues,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
setSettings,
browse index,
search into facet values,
generateSecuredApiKey,
add key,
update key
About this parameter
Sets the languages to be used by language-specific
settings and functionalities such as
ignorePlurals
, removeStopWords
,
and CJK word-detection.
queryLanguages
performs 2 roles:
-
It sets a default list of languages used by
removeStopWords
andignorePlurals
(if they are enabled). For example, if you enableignorePlurals
, the languages set inqueryLanguages
will be applied. -
It sets the dictionary for word-detecting in CJK languages (=Chinese “zh”, Japanese “ja”, or Korean “ko”). For this, you need to place the CJK language first in queryLanguages’s list of languages. For example, to ensure that Chinese word-recognition is based on a Chinese dictionary, and not the general algorithm used for all languages, you need to place Chinese in the first position of the list of languages. Likewise for Japanese and Korean, they need to be first in the list to ensure proper dictionary-based parsing. See example below.
Usage notes:
-
When working with Japanese data, you also need to set “ja” in the
indexLanguages
parameter. -
If you do not use
queryLanguages
, the engine will use either the system default (all languages) or the list of languages specified directly inignorePlurals
andremoveStopWords
. -
As already noted,
queryLanguages
creates a default list of languages. This default that can be overridden by any setting that uses the default. For example, if you set the default to English and French, you can setignorePlurals
to use the default but setremoveStopWords
to recognize only English stop words. See example below. -
For optimum relevance, it is recommended to only enable languages that are used 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 the default Query Languages
In this example, we set Spanish (‘es’) as the default language
for both ignorePlurals
and removeStopWords
1
2
3
4
5
$index->setSettings([
'queryLanguages' => ['es'],
'removeStopWords' => true,
'ignorePlurals' => true
]);
Override Query Languages
In this example, we override the Spanish default for removeStopWords
by adding Catalan (‘ca’) to its list of languages.
1
2
3
$results = $index->search('query', [
'removeStopWords' => ['ca', 'es']
]);
Set the correct dictionary for word detection
By placing ‘ja’ in the first position, this ensures that the Japanese dictionary will be used whenever the engine detects CJK logograms.
1
2
3
$results = $index->search('query', [
'queryLanguages' => ['ja', 'en']
]);