i've read mongodb documentation on getting indexes within collection, , have searched , google question. want actual indexed values.
or maybe understanding of how mongodb indexes incorrect. if i've been indexing field called text contains paragraphs, right in thinking gets indexed each word in paragraph?
either case want retrieve values indexed, db.collection.getindexes() doesn't seem returning.
well yes , no, in summary.
indexes work on "values" of fields supplied index, , "card index" in there point of reference @ find location of matches term.
what "you" seem asking here "text indexes". special index format in mongodb , other databases looks @ "text" content of field , breaks down every "word" in content value in "index".
typically do:
db.collection.createindex({ "text": "text" }) where "field name" here "text" asked, more importantly type of index here "text".
this allows insert data this:
db.collection.insert({ "text": "the quick brown fox jumped on lazy dog" }) and search this, using $text operator:
db.collection.find({ "$text": { "$search": "brown fox" } }) which return , "rank" in order terms gave in query depending how matched given "text" of field in index on collection.
note "text" index , it's query not interact on specific field. index can made on multiple fields. query , constraints on "index" there can "only one" text index present on given collection otherwise errors occur.
Comments
Post a Comment