为文本索引指定语言
指定text索引的默认语言
text索引的默认语言db.quotes.createIndex(
{ content : "text" },
{ default_language: "spanish" }
)用多种语言为集合创建文本索引
指定文档内的索引语言
使用任何字段来指定文档的语言
最后更新于
text索引的默认语言db.quotes.createIndex(
{ content : "text" },
{ default_language: "spanish" }
)最后更新于
{
_id: 1,
language: "portuguese",
original: "A sorte protege os audazes.",
translation:
[
{
language: "english",
quote: "Fortune favors the bold."
},
{
language: "spanish",
quote: "La suerte protege a los audaces."
}
]
}
{
_id: 2,
language: "spanish",
original: "Nada hay más surrealista que la realidad.",
translation:
[
{
language: "english",
quote: "There is nothing more surreal than reality."
},
{
language: "french",
quote: "Il n'y a rien de plus surréaliste que la réalité."
}
]
}
{
_id: 3,
original: "is this a dagger which I see before me.",
translation:
{
language: "spanish",
quote: "Es este un puñal que veo delante de mí."
}
}db.quotes.createIndex( { original: "text", "translation.quote": "text" } )db.quotes.createIndex( { quote : "text" },
{ language_override: "idioma" } ){ _id: 1, idioma: "portuguese", quote: "A sorte protege os audazes" }
{ _id: 2, idioma: "spanish", quote: "Nada hay más surrealista que la realidad." }
{ _id: 3, idioma: "english", quote: "is this a dagger which I see before me" }