Hi!
I ran into a problem for which I can not find an acceptable solution:
Input:
I have index of documents
{ "profile": { "mappings": { "properties": { ... "skills": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, ... } } }
Where, in fact, "skills" field is array of strings
{ ... "skills": [ "skill1", "skill2" ] ... }
I need:
- Aggregate all unique value of this field
- Amount of possible values may be big, so I need paging
- Filter aggregated values with match query.
Now I have smth like this:
{ "aggs": { "skills": { "composite": { "size": 10, "sources": [{ "skills_sub": { "terms": { "field": "skills.keyword" } } } ] } } }, "query": { "bool": { "should": [{ "match": { "skills": { "query": "value" } } } ] } }, "size": 0 }
It almost matches my requirements:
- It aggregates unique values
- I have "After" and "Size"
- It returns values, that match query. BUT it returns ALL values from array if any matches
So, if doc has field "skills" with values: "value1", "value2". And I request for "value1", I'll got both of them.
So, what I need to do, to override this behavior?