Reputation: 1336
I got entities like this in foo
index:
{ids: ["aa", "bb"]}
{ids: ["aa", "cc"]}
{ids: ["ee"]}
{ids: ["ff" , "cc"]}
Basically I want to know are there documents for ids aa
and ee
.
I tried to do it with terms aggregation
{
"size": 0,
"query": {
"bool": {
"should": [
{
"terms": {
"ids": [
"aa", "ee"
],
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"aggregations": {
"byid": {
"terms": {
"field": "ids",
"min_doc_count": 1
}
}
}
}
but the problem here that in response I got aggregation also with other ids
that selected entities have, and there are a lot of them in real case, so the aggregation for ids
that I interested in could not come in response and I will think that there is no items for them (but actually there are, but not in response because of term size limit)
I could do it for every id
separately without aggs just get a count
, but there are a lot of them and it will be very expensive.
Upvotes: 0
Views: 315
Reputation: 32376
Based on chat, found that no of documents containing the ids are not required, hence aggregation is not required, now whether a particular id is present in the search result or not is the main issue.
there are a couple of approaches:
Upvotes: 1