1

The question has been previously asked in another thread (MongoDB - Multi-key and Compound) and there is currently no solution from MongoDB. Has anyone developed a successful workaround either through indexing or document design?

Example document:

{
  timestamp: Timestamp(1234123123,0),
  values : [
     {field1:"somevalue", field2:"otherValue"},
     {field1:"somevalue2", field2:"otherValue2"}
  ]
}

Our index specifically is: timestamp : -1, values.field2:1 and the explain shows that the lower bound of the timestamp is ignored.

1 Answer 1

0

if you have complex object you need index values with defining path to this value, like that values.field2:1

db.collectionName.ensureIndex( { timestamp: -1}, {values.field2: 1} )

Also I had some kind of same question some time ago. Check out here: Mongo and Java: Create indexes for aggregation framework

Sign up to request clarification or add additional context in comments.

1 Comment

We had already created the index in the manner that you suggested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.