The totality and filtering from one index to another through the third

On my Elasticsearch server, I have three indexes: Person , Archive and Document .

  • Each document has an Archive field, which is the _id Archive in which it is located.

  • Each archive has an owner , which is an _id Person , which is the owner of the archive.

With the above indexes, I can aggregate documents into buckets of archives and archives into buckets of owners.

How can I also include documents in the aggregation of individuals, so if I filter for a specific person, I get archives and their documents that belong to a person, and not just archives?


This is what I have so far filtered and collated archives into buckets of owners:

 { "post_filter": { "terms": { "owner": [ "my_owner_id" ] } }, "aggs": { "_filter_archive": { "filter": { "terms": { "owner": [ "my_owner_id" ] } }, "aggs": { "archive": { "terms": { "field": "archive" } } } } } } 
+7
search elasticsearch faceted-search
source share
1 answer

It will be difficult to answer, because it seems that you lack details. The easy answer is to use nested documents or parent-child relationships. Which one to use in your case depends on many factors. My suggestion is to try both of them and check. See how well they work. The third option is to completely denormalize your data. This is the reason I asked about updates, how frequent they are, how big the Person document is, how big the archive document, etc. If you are not ready to answer these questions, then check the nested and parent-child and select one or Others. Good luck

+2
source share

All Articles