Create Index
db.MyCollection.createIndex({'$**': 'text'}, {name: 'FullTextIndex'})
Matching
db.MyCollection.find({$text: {$search: 'myWord'}}).count()
Result 1. for a field that has the value " myWord here "
If I perform a regular search on the selected fields as follows, I get two records, one record has a name = " myWord here " and the second record has " myWord in the Details filed as" something here, and myWord here "
db.getCollection('MyCollection').find({ "$or":[{"Name":/myWord/i}, {"Details":/myWord/i}] }).sort({"Name": 1})
How can I recreate an index so that it searches all fields like SQL, where any field, like% searchText%
And finally, how can I write this search query in C # Driver
Update:
I also looked at him. it finds all results with a search key with prefix and suffix spaces, but is not part of a line in a word.
Example: it returns an entry for Hello myWord here ", but does not return" HellomyWord "
But according to this document, it should support pattern matching. https://docs.mongodb.com/v3.0/reference/operator/query/text/
c # mongodb
Habo
source share