Hi,
I got example 2 documents
doc: 1
{
...
author: ['mike', 'adam', 'julie']
}
doc: 2
{
...
author: ['mike', 'mike stephen', 'apple']
}
in keyword search scenario, user will search "mike" with query below
{
"query": {
"match": {
"author": "mike"
}
},
"aggs": {
"field2_terms": {
"terms": {
"field": "author"
}
}
}
}
Output for aggregation is
[
{
"key": "mike",
"doc_count": 2
},
{
"key": "adam",
"doc_count": 1
},
{
"key": "julie",
"doc_count": 1
},
{
"key": "mike stephen",
"doc_count": 1
},
{
"key": "apple",
"doc_count": 1
}
]
the question is how do I get only MIKE*
for aggregation. I would like the aggregation result look like this. is it possible in elasticsearch query?
[
{
"key": "mike",
"doc_count": 2
},
{
"key": "mike stephen",
"doc_count": 1
},
]