0

I have a document that has fields engine, type, manufacturerId. I created a composite unique index on the 3 fields, so I used the following to create the index.

@CompoundIndex(name = "engine_type_manufacturerId", def = "{'engine' : 1, 'type' : 1, 'manufacturerId': 1}", unique = true)

This does the job to avoid duplicate entries for the combination of the 3 fields.

Moving on, in my application I have queries where I would search by engine only or engine & type. Now, my question is, will the composite unique index that I created earlier cover the cases for the queries on engine or engine & type OR should I create new indexes for those?

anz
  • 987
  • 7
  • 21

0 Answers0