0

My collection is:

{ "Name" : "Bhanu"}

when i execute the below query, will it returns the above doc("Name" : "Bhanu")?

db.coll.find({"Name" : "BHANU"}).collation({ locale: 'en', strength: 2  })  

Surprisingly it was returning the result ("Name" : "Bhanu") even though that i passed the parameter in upper or lower case like "BHANU" or "bhanu" .

My question is, how come that i was getting the result without creating the case insensitive index ? Can someone explain. Thanks in advance.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
  • What indexes you have, and where is your aggregation? – Alex Blex May 21 '18 at 16:20
  • i have only one index which is for _id (auto created) and i m not using any aggregation query. Just using the normal find query which i stated in the above question. – Bhanu Makineni May 21 '18 at 18:18
  • 1
    Why on the Earth you are asking about indexes and tag it as an aggregation question then? Please have a read [how to ask to get an answer](https://stackoverflow.com/help/on-topic) and may be [docs](https://docs.mongodb.com/manual/reference/method/cursor.collation/) – Alex Blex May 21 '18 at 19:23
  • As Alex stated, the documentation does cover this. The answers could be clearer on this but hey, not all answers are submitted by someone with a deep understanding of the issue. And they do "point to the documentation", so I'm not picking nits. Indexes are "preferred" but not "mandatory". Collation is as collation does. – Neil Lunn May 21 '18 at 20:15

0 Answers0