R
R
recloudor2016-08-10 11:57:51
MongoDB
recloudor, 2016-08-10 11:57:51

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)

I use MgoLabix.
Can't find what's the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy Ivakha, 2016-08-11
@ivahaev

I suspect because $caseSens i tive

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question