Continuing the discussion from ElasticSearch Filter by Aggregation Result:
This is the structure of the document which I am storing with nested relationship.
"PostContent":"I love reading Harry Potter on Apple Ipad and Amazon Kindle"
I have a post and the post is assigned certain Entities by an NLP system. I want to perform term aggregation on the Entity names like Apple, Amazon. The purpose is to find the count of posts that have a particular entity in it.
The problem here is that if I use a common term aggregation I'm returned with a lot of buckets since I have over thousands of entities. I don't want to see the buckets for all the entities. Is there any way by which I can filter the buckets returned by the term aggregation.
Approaches that I tried are:
Filtered aggregation, but that did not work since that would return the buckets with all the posts those contain these particular filtered entity names but those documents can have multiple entities. So in that case, again I will get too many entities in the term aggregation which I don't require.
Another option I cam across is Filtering values in Term aggregations using include and exclude https://www.elastic.co/guide/en/elasticsearch/reference/1.4/search-aggregations-bucket-terms-aggregation.html#_filtering_values
but even this might not work for me since this would not take multiple terms as I would like to filter for multiple entities.
Another option which was pointed by someone was Bucket Selector, but again with Bucket Selector we have to use a script and will I be able to filter for multiple entities using script?
Could you please suggest any alternatives for my use case?