I have a collection structured like this:
tag_analytics:
{
tag_id: "test1",
zips: [ {zip_code: "90210", value: 2}, {zip_code: "90310", value: 4} ],
report_time:ISODate("2014-03-23T00:00:00"),
value1: 1,
value2: 2
}
I am curious how I would make an index for the following update call:
db.tag_analytics.update({report_time:ISODate("2014-04-23T00:00:00"), tag_id: "test1", "zips.zip_code":"90210"},{$inc:{zips.$.value":10}});
If I needed to guess it would be
db.tag_analytics.ensureIndex({report_time:-1, tag_id:1, "zips.zip_code":1});
but I am unsure if my zips.zip_code should be first or last, or if it is possible to index this query at all. Any help would be greatly appreciated.
Thank you,