mongodb $text 全文搜索如何实现OR?

浏览:67日期:2023-06-15

问题描述

''ssl certificate' authority key'

The $text operator searches for the phrase 'ssl certificate' and ('authority' or 'key' or 'ssl' or 'certificate' ).

这是文档里的一个例子,使用'括起来的叫做Phrases,mongodb为它执行and操作,其他词用空格分割执行or操作。

{'$text': {'$search': ''ssl certificate' authority key'}}的搜索结果一定会包含'ssl certificate'。有没有方法可以对’ssl certificate’, ’authority’, ’key’实现or的全文搜索呢?

问题解答

回答1:

在您的需求中,当前的作法是:分为2个语句来查询,

1、查询phrase:''ssl certificate''

2、查询单独的单词:'authority key'

再把两个语句的结果在程序中合并一处。

供参考。

Love MongoDB! Have Fun!

MongoDB中文社区深圳用户大会

这个周六,大家约起

详情请入

请大家多参与深圳用户大会,多给深圳的几位大拿提问题呀mongodb $text 全文搜索如何实现OR?

相关文章: