问题
I set up a compound text index on two fields on my collection. I want to perform a text search on these two fields. Testing it out with the following command gave me satisfactory results.
db.collection.find({$text: {$search: "term"}}, {score: {$meta: "textScore"}}).sort({score:{$meta:"textScore"}})
However, I would like to know along with each result which of the two indexed fields matched the search term.
Is this possible? It seems so incredibly basic and I can't find support for this feature.
来源:https://stackoverflow.com/questions/45227276/how-to-identify-the-matching-fields-for-mongodb-text-search