Multi field terms facet


(nmosafi) #1

Hi there

I am trying to use the multi field terms facet. Say I have documents which look like this:

{
"fruit": "apple",
"colour": "green",
"size": "large"
},
{
"fruit": "banana",
"colour": "yellow",
"size": "large"
},
{
"fruit": "grape",
"colour": "green",
"size": "small"
}

and I run a multi terms facet:

{
"query": { "match_all": {} },
"size": 0,
"facets": { "myFacet": { "terms": { "fields" : ["colour", "size"] } } }
}

Here I am trying to get three facets to be returned

{"terms": [ "green", "large" ], "count": 1 }
{"terms": [ "yellow", "large" ], "count": 1 }
{"terms": [ "green", "small" ], "count": 1 }

However I get back this

{"term": "green", "count": 2 }
{"term": "yellow", "count": 1 }
{"term": "large", "count": 2 }
{"term": "small", "count": 1 }

Is there a way to achieve what I am trying?


(system) #2