不同的正则表达式和文本搜索结果

时间:2019-01-02 15:32:14

标签: mongodb full-text-search full-text-indexing

我使用正则表达式和文本搜索查询mongo文档的结果不同。如果我使用正则表达式,我将获得结果:

  

db.planning.find({“ year”:2018,“ data”:{$ regex:“。*#A。*”}}})

{ "_id" : ObjectId("5bf2964723eeeb59ef26dc69"), "date" : ISODate("2018-04-10T00:00:00Z"), "month" : 4, "instrument" : "AV500", "day" : 10, "data" : "N2 / Zizic #A (MP)", "year" : 2018 }
{ "_id" : ObjectId("5bf2964823eeeb59ef26dcd5"), "date" : ISODate("2018-04-11T00:00:00Z"), "month" : 4, "instrument" : "AV500", "day" : 11, "data" : "Zizic #A (MP)", "year" : 2018 }
{ "_id" : ObjectId("5bf2964823eeeb59ef26dccd"), "date" : ISODate("2018-04-12T00:00:00Z"), "month" : 4, "instrument" : "AV500", "day" : 12, "data" : "Zizic #A (MP)", "year" : 2018 }

如果我使用text search,则不会获得结果:

  

db.planning.find({“ year”:2018,$ text:{$ search:“ #A”}})

有原因吗? #在mongo中是特殊字符吗?

0 个答案:

没有答案