How to identify the matching field(s) for MongoDB text search?

↘锁芯ラ 提交于 2019-12-11 04:31:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!