Full Text Search in MongoDB not yielding the expected result for “@@@”

前端 未结 2 1218
南方客
南方客 2021-01-21 19:47

So I have a document in a collection with on of the fields having a value \"@@@\" I indexed the collection and tried running the query:

db.getCollection(\'TestColl

2条回答
  •  时光取名叫无心
    2021-01-21 20:29

    Your query has to many curly braces, remove them:

    db.getCollection('so2').find({$text:{$search:"\"@@@\""}})
    

    If you run it, Mongo tells you you're missing a text index. Add it like this:

    db.so2.createIndex( { field2: "text" } )
    

    The value you're using is pretty small. Try using longer values.

提交回复
热议问题