I have a rather complicated aggregation; its complexity is caused by the lack of has_parent aggregation. Since it is implemented using groovy. The only problem I am facing is filtering out documents counted in aggregation.
The aggregation is as follows: https://gist.github.com/serj-p/c4fcc9810b3b627de294 the purpose of this association is to build the pinnacle of contact with universities. The contact document has child documents, which are facebook profiles. The latter have nested fields representing universities, so I refer to the _source field.
As you probably see, I'm filtering at the beginning:
{ "match_phrase_prefix": { "organizations.name": "stan" } }
to exclude contacts that do not have relevant documents. "organization.name" parsed as
{ "filter": [ "lowercase", "standard", "trim", "asciifolding", ], "type": "custom", "tokenizer": "standard" }
text that is an applicator for filtering this field is analyzed in a similar way. It was very difficult for me to do the same processing of the field value and the filtering text inside the script, which should filter certain attached documents. This is why I am looking for some opportunity to access the ES API from a script to do this.
Thanks in advance for any advice.
elasticsearch
Serj
source share