mongodb $text 全文搜索如何实现OR?
迷茫
迷茫 2017-05-02 09:26:13
0
1
577

"\"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的全文搜索呢?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

Antworte allen(1)
習慣沉默

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

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

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

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

供参考。

Love MongoDB! Have Fun!


MongoDB中文社区深圳用户大会

这个周六,大家约起

详情请入

请大家多参与深圳用户大会,多给深圳的几位大拿提问题呀

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!