Aggregate field which should appeared in both matched documents?

i have documents like below in my books index.

   id: 1,
   "title": "Story of middle man"
   "category": ['kids', 'comedy', 'action']

  id: 2,
  title: "The story of young adult",
  category: ['adult', 'region', 'romantic', 'action']

now my query needs to find docs which has "middle" or "young" in title. so both document will match then i want to aggregate over category field. so my question here is how to find the category which appear in both docs. for example "action" is the only category which appeared in both matched results which has "young" and "middle". is it possible to write elasticsearch query for this case.

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