so i am struggling for 2 weeks on why does not my indexes get picked when i “explain” my queries.
i have this query:
{
“$and”: [{ "extraProperties.class": "Residential" }, { "extraProperties.type": "Sale" }, { "extraProperties.propertyType": "Condo Apartment" }, { "extraProperties.propertyTypeStyle": "Apartment" }
]
}
the above query wont pick this index :
{ “extraProperties.class”:1 , “extraProperties.type” : 1, “extraProperties.propertyType”:1,“extraProperties.propertyTypeStyle”:1}
i have been testing everything these days and finally i decided to flatten the hierarchy and now my query looks like this:
{
“$and”: [{
“class”: “Residential”
},
{
“type”: “Sale”
},
{
“propertyType”: “Condo Apartment”
},
{
“propertyTypeStyle”: “Apartment”
}]
}
now the above query will pick this index :
{ “class”:1 , “type” : 1, “propertyType”:1,“propertyTypeStyle”:1}
could someone explain what the hell is going on there?!?!