複数の配列フィールドを持つオブジェクトのコレクションがあります。何かのようなもの:
{
sponsors: {
lead_sponsor: {
name: "Mark",
type: "Individual"
}
collaborators: [
{name: "Company Ltd.", type: "Company"},
{name: "Industry Company Ltd.", type: "Company"}
]
},
terms: ["Some term", "Some term 2", "Some term 3"],
keywords: ["word1", "word2", "word3", "word4"],
description: "Here might be big text with detailed description",
status: "Active",
}
次のようなクエリを最適化するにはどうすればよいですか?
{
status: "Active",
$or: [
{"lead_sponsor.name": /company/i},
{"collaborators.name": /company/i},
{"terms": /phrase/i},
{"keywords": /phrase/i},
{"description": /phrase/i},
]
}
複合インデックスは、複数の配列フィールドを持つことはできません。配列フィールドからすべてのデータを新しいフィールドにコピーし、searchArray
この配列のみを含む複合インデックスを追加すると効果がありますか? それは良いアプローチですか?