Answer the question
In order to leave comments, you need to log in
Go, MongoDB. How to implement text search?
topicsCollection := DB.C("topics")
var topics []ItemDocument
err := topicsCollection.EnsureIndexKey("title")
if err != nil {
fmt.Println(err)
}
topicsCollection.Find(bson.M{
"$text": bson.M{
"$search": query,
"$caseSensetive": false,
},
}).Limit(10).All(&topics)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question