Difficulties with aggregations

Hi!
I'm a beginner in Elasticsearch queries and I have difficulties with aggregations.
To explain easily my problem, I will work with an example:

Imagine I have planted tomatoes and carrots in several fields.
So each field have tomatoes, carrots, or both.

In Elasticsearch, they are all in the same index with parent/child relations between fields - tomatoes and fields - carrots (because they are one-to-many relations and I think it could help me with my aggregations). Each tomato and carrot has also the id of their field.

I want to know how much carrots (in total) are planted next to tomatoes in one request (this amounts to count how much they are carrots planted in all the fields except in the fields that don't contain tomatoes).

I tried different things, using pipeline aggregations, has_parent/has_child, but I still don't see how to get the results, even if it seems a simple query.

Can you give me tips that can help me?

Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.