POST test/_doc/
{
"food": [
{
"food1": {
"type": "Western food",
"name": "hamburger"
},
"food2": {
"type": "Japanese food",
"name": "sushi"
}
}
]
}
POST test/_doc/
{
"food": [
{
"food1": {
"type": "Chinese food",
"name": "jajangmyeon"
},
"food2": {
"type": "Western food",
"name": "steak"
}
}
]
}
This code is my sample code. I want to create a query that counts the number of fields food1 and food2 by 'type' field. I want the output like the code below.
{
"key": "Western food",
"doc_count": 2
},
{
"key": "Chinese food",
"doc_count": 1
},
{
"key": "Japanese food",
"doc_count": 1
}