Collation Locales and Default Parameters排序规则区域设置和默认参数

On this page本页内容

New in version 3.4.版本3.4中的新功能。

Collation排序规则 allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.允许用户为字符串比较指定特定于语言的规则,例如字母大小写和重音符号的规则。

Behavior行为

Some collation locales have variants, which employ special language-specific rules. 一些排序规则区域设置有变体,它们使用特定于语言的特殊规则。To specify a locale variant, use the following syntax:要指定区域设置变量,请使用以下语法:

{ "locale" : "<locale code>@collation=<variant>" }

For example, to use the unihan variant of the Chinese collation:例如,要使用中文排序规则的unihan变体:

{ "locale" : "zh@collation=unihan" }

See the collation page for a full description of collation behavior and syntax.有关排序规则行为和语法的完整描述,请参阅排序规则页面。

Supported Languages and Locales支持的语言和地区

MongoDB’s collation feature supports the following languages. MongoDB的排序规则功能支持以下语言。The following table lists the supported languages and the associated locales as defined by ICU Locale ID. 下表列出了受支持的语言以及ICU Locale ID定义的相关语言环境。[1]

LanguageLocaleVariants
Afrikaansaf 
Albaniansq 
Amharicam 
Arabicarcompat
Armenianhy 
Assameseas 
Azeriazsearch
Bengalibn 
Belarusianbe 
Bengalibntraditional
Bosnianbssearch
Bosnian (Cyrillic)bs_Cyrl 
Bulgarianbg 
Burmesemy 
Catalancasearch
Cherokeechr 
Chinesezh
big5han
gb2312han
unihan
zhuyin
Chinese (Traditional)zh_Hant 
Croatianhrsearch
Czechcssearch
Danishdasearch
Dutchnl 
Dzongkhadz 
Englishen 
English (United States)en_US 
English (United States, Computer)en_US_POSIX 
Esperantoeo 
Estonianet 
Eweee 
Faroesefo 
Filipinofil 
Finnishfi
search
traditional
Frenchfr 
French (Canada)fr_CA 
Galicianglsearch
Georgianka 
Germande
search
eor
phonebook
German (Austria)de_ATphonebook
Greekel 
Gujaratigu 
Hausaha 
Hawaiianhaw 
Hebrewhesearch
Hindihi 
Hungarianhu 
Icelandicissearch
Igboig 
Inari Samismnsearch
Indonesianid 
Irishga 
Italianit 
Japanesejaunihan
LanguageLocaleVariants
Kalaallisutklsearch
Kannadakntraditional
Kazakhkk 
Khmerkm 
Konkanikok 
Koreanko
search
searchjl
unihan
Kyrgyzky 
Lakotalkt 
Laolo 
Latvianlv 
Lingalalnphonetic
Lithuanianlt 
Lower Sorbiandsb 
Luxembourgishlb 
Macedonianmk 
Malayms 
Malayalamml 
Maltesemt 
Marathimr 
Mongolianmn 
Nepaline 
Northern Samisesearch
Norwegian Bokmålnbsearch
Norwegian Nynorsknnsearch
Oriyaor 
Oromoom 
Pashtops 
Persianfa 
Persian (Afghanistan)fa_AF 
Polishpl 
Portuguesept 
Punjabipa 
Romanianro 
Russianru 
Serbiansr 
Serbian (Latin)sr_Latnsearch
Sinhalasidictionary
Slovaksksearch
Sloveniansl 
Spanishes
search
traditional
Swahilisw 
Swedishsvsearch
Tamilta 
Telugute 
Thaith 
Tibetanbo 
Tonganto 
Turkishtrsearch
Ukrainianuk 
Upper Sorbianhsb 
Urduur 
Uyghurug 
Vietnamesevitraditional
Walserwae 
Welshcy 
Yiddishyisearch
Yorubayo 
Zuluzu 

Tip

To explicitly specify simple binary comparison, specify locale value of "simple".要显式指定简单二进制比较,请指定"simple"locale(区域设置)值。

[1]To request support for a locale, please file a JIRA ticket with the Server project要请求对区域设置的支持,请向服务器项目提交JIRA票证

Collation Default Parameters排序规则默认参数

A collation document contains several optional parameters in addition to the required locale parameter. 除了必需的locale参数外,排序规则文档还包含几个可选参数Depending on which locale you use, the default parameters may be different. 根据您使用的默认locale参数可能不同。See the collation page for a full description of collation syntax.有关排序规则语法的完整描述,请参阅排序规则页面。

The following default parameters are consistent across all locales:以下默认参数在所有地区都是一致的:

The following table shows the default collation parameters which may vary across different locales:下表显示了默认排序规则参数,这些参数在不同的地区可能有所不同:

LocalecaseFirstalternatenormalizationbackwards
afoffnon-ignorableFALSEFALSE
sqoffnon-ignorableFALSEFALSE
amoffnon-ignorableFALSEFALSE
aroffnon-ignorableFALSEFALSE
ar@collation=compatoffnon-ignorableFALSEFALSE
hyoffnon-ignorableFALSEFALSE
asoffnon-ignorableTRUEFALSE
azoffnon-ignorableFALSEFALSE
az@collation=searchoffnon-ignorableTRUEFALSE
beoffnon-ignorableFALSEFALSE
bnoffnon-ignorableTRUEFALSE
bn@collation=traditionaloffnon-ignorableTRUEFALSE
bsoffnon-ignorableFALSEFALSE
bs@collation=searchoffnon-ignorableTRUEFALSE
bs_Cyrloffnon-ignorableFALSEFALSE
bgoffnon-ignorableFALSEFALSE
myoffnon-ignorableTRUEFALSE
caoffnon-ignorableFALSEFALSE
ca@collation=searchoffnon-ignorableTRUEFALSE
chroffnon-ignorableFALSEFALSE
zhoffnon-ignorableFALSEFALSE
zh@collation=big5hanoffnon-ignorableFALSEFALSE
zh@collation=gb2312hanoffnon-ignorableFALSEFALSE
zh@collation=unihanoffnon-ignorableFALSEFALSE
zh@collation=zhuyinoffnon-ignorableFALSEFALSE
zh_Hantoffnon-ignorableFALSEFALSE
hroffnon-ignorableFALSEFALSE
hr@collation=searchoffnon-ignorableTRUEFALSE
csoffnon-ignorableFALSEFALSE
cs@collation=searchoffnon-ignorableTRUEFALSE
dauppernon-ignorableFALSEFALSE
da@collation=searchoffnon-ignorableTRUEFALSE
nloffnon-ignorableFALSEFALSE
dzoffnon-ignorableFALSEFALSE
enoffnon-ignorableFALSEFALSE
en_US_POSIXoffnon-ignorableFALSEFALSE
en_USoffnon-ignorableFALSEFALSE
eooffnon-ignorableFALSEFALSE
etoffnon-ignorableFALSEFALSE
eeoffnon-ignorableFALSEFALSE
fooffnon-ignorableFALSEFALSE
fo@collation=searchoffnon-ignorableTRUEFALSE
filoffnon-ignorableFALSEFALSE
fioffnon-ignorableFALSEFALSE
fi@collation=searchoffnon-ignorableTRUEFALSE
fi@collation=traditionaloffnon-ignorableFALSEFALSE
froffnon-ignorableFALSEFALSE
fr_CAoffnon-ignorableFALSETRUE
gloffnon-ignorableFALSEFALSE
gl@collation=searchoffnon-ignorableTRUEFALSE
kaoffnon-ignorableFALSEFALSE
deoffnon-ignorableFALSEFALSE
de@collation=searchoffnon-ignorableTRUEFALSE
de@collation=phonebookoffnon-ignorableFALSEFALSE
de@collation=eoroffnon-ignorableFALSEFALSE
de_AToffnon-ignorableFALSEFALSE
de_AT@collation=phonebookoffnon-ignorableFALSEFALSE
eloffnon-ignorableTRUEFALSE
guoffnon-ignorableTRUEFALSE
haoffnon-ignorableFALSEFALSE
hawoffnon-ignorableFALSEFALSE
heoffnon-ignorableTRUEFALSE
he@collation=searchoffnon-ignorableTRUEFALSE
hioffnon-ignorableTRUEFALSE
huoffnon-ignorableFALSEFALSE
isoffnon-ignorableFALSEFALSE
is@collation=searchoffnon-ignorableTRUEFALSE
igoffnon-ignorableTRUEFALSE
smnoffnon-ignorableFALSEFALSE
smn@collation=searchoffnon-ignorableTRUEFALSE
idoffnon-ignorableFALSEFALSE
gaoffnon-ignorableFALSEFALSE
itoffnon-ignorableFALSEFALSE
jaoffnon-ignorableFALSEFALSE
ja@collation=unihanoffnon-ignorableFALSEFALSE
kloffnon-ignorableFALSEFALSE
kl@collation=searchoffnon-ignorableTRUEFALSE
knoffnon-ignorableTRUEFALSE
kn@collation=traditionaloffnon-ignorableTRUEFALSE
kkoffnon-ignorableFALSEFALSE
kmoffnon-ignorableTRUEFALSE
kokoffnon-ignorableTRUEFALSE
kooffnon-ignorableFALSEFALSE
ko@collation=searchoffnon-ignorableTRUEFALSE
ko@collation=searchjloffnon-ignorableTRUEFALSE
ko@collation=unihanoffnon-ignorableFALSEFALSE
kyoffnon-ignorableFALSEFALSE
lktoffnon-ignorableFALSEFALSE
looffnon-ignorableFALSEFALSE
lvoffnon-ignorableFALSEFALSE
lnoffnon-ignorableFALSEFALSE
ln@collation=phoneticoffnon-ignorableFALSEFALSE
ltoffnon-ignorableFALSEFALSE
dsboffnon-ignorableFALSEFALSE
lboffnon-ignorableFALSEFALSE
mkoffnon-ignorableFALSEFALSE
msoffnon-ignorableFALSEFALSE
mloffnon-ignorableFALSEFALSE
mtuppernon-ignorableFALSEFALSE
mroffnon-ignorableTRUEFALSE
mnoffnon-ignorableFALSEFALSE
neoffnon-ignorableFALSEFALSE
seoffnon-ignorableFALSEFALSE
se@collation=searchoffnon-ignorableTRUEFALSE
nboffnon-ignorableFALSEFALSE
nb@collation=searchoffnon-ignorableTRUEFALSE
nnoffnon-ignorableFALSEFALSE
nn@collation=searchoffnon-ignorableTRUEFALSE
oroffnon-ignorableTRUEFALSE
omoffnon-ignorableFALSEFALSE
psoffnon-ignorableTRUEFALSE
faoffnon-ignorableTRUEFALSE
fa_AFoffnon-ignorableTRUEFALSE
ploffnon-ignorableFALSEFALSE
ptoffnon-ignorableFALSEFALSE
paoffnon-ignorableTRUEFALSE
rooffnon-ignorableFALSEFALSE
ruoffnon-ignorableFALSEFALSE
sroffnon-ignorableFALSEFALSE
sr_Latnoffnon-ignorableFALSEFALSE
sr_Latn@collation=searchoffnon-ignorableTRUEFALSE
sioffnon-ignorableTRUEFALSE
si@collation=dictionaryoffnon-ignorableTRUEFALSE
skoffnon-ignorableFALSEFALSE
sk@collation=searchoffnon-ignorableTRUEFALSE
sloffnon-ignorableFALSEFALSE
esoffnon-ignorableFALSEFALSE
es@collation=searchoffnon-ignorableTRUEFALSE
es@collation=traditionaloffnon-ignorableFALSEFALSE
swoffnon-ignorableFALSEFALSE
svoffnon-ignorableFALSEFALSE
sv@collation=searchoffnon-ignorableTRUEFALSE
taoffnon-ignorableTRUEFALSE
teoffnon-ignorableTRUEFALSE
thoffshiftedTRUEFALSE
booffnon-ignorableFALSEFALSE
tooffnon-ignorableFALSEFALSE
troffnon-ignorableFALSEFALSE
tr@collation=searchoffnon-ignorableTRUEFALSE
ukoffnon-ignorableFALSEFALSE
hsboffnon-ignorableFALSEFALSE
uroffnon-ignorableFALSEFALSE
ugoffnon-ignorableFALSEFALSE
vioffnon-ignorableTRUEFALSE
vi@collation=traditionaloffnon-ignorableTRUEFALSE
waeoffnon-ignorableFALSEFALSE
cyoffnon-ignorableFALSEFALSE
yioffnon-ignorableTRUEFALSE
yi@collation=searchoffnon-ignorableTRUEFALSE
yooffnon-ignorableTRUEFALSE
zuoffnon-ignorableFALSEFALSE