アプリケーションでmongoテキスト検索を使用しています。
索引:
db.test.createIndex(
{
title: 'text',
description: 'text'
},
{
name: "TextIndex",
weights: {
title: 10,
description: 1
}
}
)
スコア:
title : 10
description : 1
書類:
db.test.insert(
[
{ _id: 1, title: "agent de production", description: "production or agent"},
{ _id: 2, title: "agent test production", description: "agent" },
{ _id: 3, title: "production agent", "description" : "production"},
{ _id: 4, title: "agent", "description" : "production"},
{ _id: 5, title: "test", "description" : "production example agent"},
]
)
質問
「エージェント プロダクション」で検索すると
結果は
[
{ _id: 1, title: "agent de production", description: "production or agent"},
{ _id: 2, title: "agent test production", description: "agent" },
{ _id: 3, title: "production agent", "description" : "production"},
{ _id: 5, title: "test", "description" : "production example agent"},
]
私が試したこと:
db.test.find({"$text" : {"$search" : "\"agent production\""}}); Query result does not match with the expected result.
結果:なし
クエリフレーズ: db.test.find({"$text" : {"$search" : "\"agent\" \"production\""}})
結果:
{ "_id" : 5, "title" : "test", "description" : "production example agent" }
{ "_id" : 1, "title" : "agent de production", "description" : "production or agent" }
{ "_id" : 3, "title" : "production agent", "description" : "production" }
{ "_id" : 2, "title" : "agent test production", "description" : "agent" }
{ "_id" : 4, "title" : "agent", "description" : "production" }
どんな提案でも感謝します。