0

'''select count(*) as count from activity where project_id in (61,129) and (entry_device_id in (1068,1069) or exit_device_id in (1068,1069) );'''

I tried with should in elastic query and match but not getting the desired results.

Got some idea from elasticsearch bool query combine must with OR

And tried but not getting the correct results.

Need help in this

1 Answers1

0

Depending on your index's mapping, a combination of terms queries should get you started:

GET your_activity_index/_count
{
  "query": {
    "bool": {
      "must": [
        {
          "terms": {
            "project_id": [ 61, 129 ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "terms": {
                  "entry_device_id": [ 1068, 1069 ]
                }
              },
              {
                "terms": {
                  "exit_device_id": [ 1068, 1069 ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}
Joe - GMapsBook.com
  • 15,787
  • 4
  • 23
  • 68