Hi fellows
I checked this forum and stackoverflow but couldn't find a matching discussion while thinking this must arise to someone before already. So I'd be happy for any help. Let's come to the point:
I want to perform a search with facet calculation returning objects as facets insteads of single values.
My mapping looks as follows (excerpt):
"myConfiguration": {"properties": {"paint": {"properties": {"code": {"type": "string"},"text": {"type": "string"}}}}}
My query currently looks like this:
{
"facets": {
"tag": {
"terms": { "field": "myConfiguration.paint.code" }
} } }
This works for the case of retrieving all paint codes used in my data set.
{
"facets": {
"tag": {
"_type": "terms", "missing": 1, "total": 525, "other": 0,
"terms": [
{
"term": "4",
"count": 20
},
{
"term": "2",
"count": 10
},
{
"term": "5",
"count": 3
}
] } } }
However, the text is what I am also interested in. What I rather want to have is something like the following:
{
"facets": {
"tag": {
"_type": "terms", "missing": 1, "total": 525, "other": 0,
"terms": [
{
"term": {"code":"4", "text":"yellow"},
"count": 20
},
{
"term": {"code":"2", "text":"black"},
"count": 10
},
{
"term": {"code":"5", "text":"white"},
"count": 3
}
] } } }
Is this possible at all and if yes how can I achieve that? Thanks in advance!!!
Stefan
(keyword: facets, aggregation, term, query, search)