MongoDB full-text search index: error: too much text index, why?

I have one problem, I have a collection, and I want to set the text search index in 2 fields (description and name). But when I add the second index, I get the following error and the text search stops working.

{ "serverUsed" : "localhost/127.0.0.1:27017" , "ok" : 0.0 , "errmsg" : "too many text index for: testdb.users"}

when I delete one index search, get started again. what is the problem? One collection supports full-text search index for only one field ????

I am using the current version of mongodb under windows, and I am using the mongodb java driver API.

thanks

+4
source share
2 answers

MongoDB .

, :

db.collection.ensureIndex( {
    description: "text",
    title: "text"
} );

, , . , , , , , , .

  • , , .
  • . , , , , _id .
+7

, db.collectionName.ensureIndex({'textColumnName': 'text'}). i.e. db.collectionName.find({$text: {$search:'your text here'}}). , , , : db.collectionName.find({$text: {$search:'your text here'}}, {score: {$meta: 'textScore'}}).sort({score: {$meta: 'textScore'}}).

title movies, db.movies.find( { $text : { $search : "Big Lebowski" } } ). , :

  • { "title" : "The Big Lebowski" , star: "Jeff Bridges" }

  • { "title" : "Big" , star : "Tom Hanks" }

  • { "title" : "Big Fish" , star: "Ewan McGregor" }

, Big Lebowski *** ***.

+1

All Articles