The following is one of the document in the MongoDB database.
I want to select the year between 2007 ,2008.
and the key includes "Actual" or "Upper End of Range"
and the table_name equals to Unemployment rate
How to finish it in Mongoid or MongoDB query.
Or I only can do it in application layer like Ruby or Python ?
id 2012-04-25_unemployment_rate
{
"_id": "2012-04-25_unemployment_rate",
"table_name": "Unemployment rate",
"unit": "Percent",
"data": [
{
"2007": [
{
"Actual": "3.5"
},
{
"Upper End of Range": "-"
},
{
"Upper End of Central Tendency": "-"
},
{
"Lower End of Central Tendency": "-"
},
{
"Lower End of Range": "-"
}
]
},
{
"2008": [
{
"Actual": "1.7"
},
{
"Upper End of Range": "-"
},
{
"Upper End of Central Tendency": "-"
},
{
"Lower End of Central Tendency": "-"
},
{
"Lower End of Range": "-"
}
]
}
}
id 2014-04-25_unemployment_rate
{
"_id": "2014-04-25_unemployment_rate",
"table_name": "Unemployment rate",
"unit": "Percent",
"data": [
{
"2008": [
{
"Actual": "3.5"
},
{
"Upper End of Range": "-"
},
{
"Upper End of Central Tendency": "-"
},
{
"Lower End of Central Tendency": "-"
},
{
"Lower End of Range": "-"
}
]
},
{
"2009": [
{
"Actual": "1.7"
},
{
"Upper End of Range": "-"
},
{
"Upper End of Central Tendency": "-"
},
{
"Lower End of Central Tendency": "-"
},
{
"Lower End of Range": "-"
}
]
}
}