0

I have a collection with elements like this:

{
name: "Smith",
fields: [10, 20, 30]
}

Is there a way to select documents where second value of fields array ( fields[1]) > 15 ?

filimonic
  • 3,988
  • 2
  • 19
  • 26

1 Answers1

2

One solution is:

 //create multikey index on field
db.test.createIndex({"fields.1" : 1})

db.test.find({"fields.1" : {$gt : 15}})
Minh Tuan Nguyen
  • 1,026
  • 8
  • 13