I would like to query the sub-key of an array, extract keywords, and count them.
The words that I'd like to extract from are in "Title." When I applied the query filter, it shows that the field I need to query is Reviews.0.Title
. But I have at least 200 elements inside the Reviews
array.
How do I do this?
{
"_id" : ObjectId("561c3ccc4c97f053753f1a78"),
"Reviews" :
[
{
"Ratings" : {
"Service" : "4",
"Overall" : "5"
},
"Location" : "MIS",
"Title" : "“Excellent and great”",
"Author" : "JDoe",
"ReviewID" : "1",
"Date" : "March 30, 2015"
},
{
"Ratings" : {
"Service" : "4",
"Overall" : "5"
},
"Location" : "WIS",
"Title" : "“Excellent and fantastic!”",
"Author" : "John Doe",
"ReviewID" : "2",
"Date" : "March 27, 2016"
}
],
"Info" :
{
"Name" : "AA",
"ID" : "0001"
}
}
{
"_id" : ObjectId("561c3ccc4c97f0ytu7289074"),
"Reviews" :
[
{
"Ratings" : {
"Service" : "4",
"Overall" : "5"
},
"Location" : "VEG",
"Title" : "“Not too bad”",
"Author" : "JDoe",
"ReviewID" : "3",
"Date" : "March 30, 2015"
},
{
"Ratings" : {
"Service" : "4",
"Overall" : "5"
},
"Location" : "NEV",
"Title" : "“Outstanding service”",
"Author" : "John Doe",
"ReviewID" : "4",
"Date" : "March 27, 2016"
}
],
"Info" :
{
"Name" : "BB",
"ID" : "0002"
}
}
I would like to get the following output:
{ "_id" : "Excellent", "value" : 1 }
{ "_id" : "Great", "value" : 1 }
{ "_id" : "Location", "value" : 2 }
edited output with name:
{ "Name" : AA: "Excellent", "value" : 1 "Great", "value" : 1 }
{ "Name" : BB: "Great", "value" : 1 }