Query to Select Document based on only one object to be present under Node

Hi,

We have data indexed as below

{
  "tags": {
    "firstlevel": {
      "events": [],
      "promotions": []
    }
  }
}

Data can be something like which has both events and promotions, just events or just promotions.

Requirement is like If i am only searching for events, I should match documents just having events as an array. Currently it is returning if events are matched but promotions are also present.

Hi @Harinder_Singh

From what I understand you only want doc with items in the events array, the promotions array must be empty.

In this case I would try to combine a must events equals xpto and an exists query in the promotions field inside a must_not. So the return would only be docs with events. Maybe this works on the data you cited so far.

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