Hello there,
I'm looking for a solution to filter some aggregation terms based on an array
field.
Here's an example of data:
PUT /test-index
POST /test-index/_doc/
{
"type": "album",
"authors": [1, 2, 3, 4, 5]
}
POST /test-index/_doc/
{
"type": "album",
"authors": [1, 2]
}
POST /test-index/_doc/
{
"type": "vinyle",
"authors": [3]
}
And the tried solutions:
Query filter not working
GET test-index/_search
{
"query": {
"bool": {
"should": [],
"must": [],
"filter": [
{
"terms": {
"authors": [
1,
2
]
}
}
]
}
},
"size": 0,
"aggs": {
"authors_type": {
"terms": {
"size": 10,
"field": "authors"
}
}
}
}
Aggregation filter not working either
GET test-index/_search
{
"size": 0,
"aggs": {
"author_types": {
"filter": {
"terms": {
"authors": [
1,
2
]
}
},
"aggs": {
"foo2": {
"filter": {
"terms": {
"authors": [
1,
2
]
}
},
"aggs": {
"foo3": {
"terms": {
"field": "authors"
}
}
}
}
}
}
}
}
Both responses includes data with other authors than 1 & 2 as mentioned.
Someone faced this issue too?
Should I have to update the index to use the nested
+ inner_hits
combo?
Thanks,
Guillaume