Skip to content
#

diary

Here are 253 public repositories matching this topic...

lanlin
lanlin commented Apr 26, 2019

背景

话说,企图用 MongoDB 全文检索来替代搜索引擎的可以放弃了。
什么分词、评分就不说了,连模糊匹配都做不到。

建议

实在需要的,可以配合上正则检索一起使用。

// demo for find
db.articles.find(
   { $or: [
          { $text: { $search: "cake" } },
          { my_field_a: /cake/ },         // my_field_a 必须建立索引
          { my_field_b: /cake/ },         // my_field_b 必须建立索引
          ...
    ] }
);

// demo for aggregate
db.a

Improve this page

Add a description, image, and links to the diary topic page so that developers can more easily learn about it.

Curate this topic

Add this topic to your repo

To associate your repository with the diary topic, visit your repo's landing page and select "manage topics."

Learn more

You can’t perform that action at this time.