I would like a query which it returns the number of times a field is repeated, according to the unique value of another field I have this json:
"name" : james,
"city" : "chicago" <----------- same
},
{
"name" : james,
"city" : "san francisco"
},
{
"name" : james,
"city" : "chicago" <-----------same
},
{
"name" : Mike,
"obtained_from" : "chicago"
},
{
"name" : Mike,
"obtained_from" : "texas"<-----------same
},
{
"name" : Mike,
"obtained_from" : "texas"<-----------same
},
{
"name" : Peter,
"obtained_from" : "chicago"
},
I want to make a query where I count based on the unique value of two fields. For example, james is equal to 2, because there are two equal fields (name: james, city, chicago) and a different field (name: james, city: san francisco) The output would then be the following:
{
"key" : "james",
"doc_count" : 2
},
{
"key" : "Mike",
"doc_count" : 2
},
{
"key" : "Peter",
"doc_count" : 3
},
It is possible to do a single value count of two fields?