MongoDB - Logical OR when searching for words and phrases using full text search

前端 未结 1 1600
情书的邮戳
情书的邮戳 2021-02-10 09:05

I asked a related question previously, and as suggested by the poster there have created this new question as a follow up:

MongoDB full text search - matching words and

相关标签:
1条回答
  • 2021-02-10 09:40

    I combed the docs on text search, and I'm afraid I don't think this is possible as of MongoDB 2.6. MongoDB's text search support is simply not as complete as a bona fide full text search engine (e.g. Solr/things built with the Lucene text search library). Right now, there's no support for boolean operators in text queries, so you cannot change the meaning of "late delay \"on time\"" from "(late OR delay) AND (\"on time\")" to "late OR delay OR \"on time\"". There might be some workarounds involving storing an array of tokens instead of or in addition to the text, or synchronizing with a full text search engine like ElasticSearch, but I'd rather know a bit more about the use case for the query before recommending any solutions.

    0 讨论(0)
提交回复
热议问题