Combine Should and Must


(Vikram) #1

nodeid = 1234 AND channel = 1 AND ( objects = car OR objects = truck ) AND ( conditions = day OR conditions = dusk )

on the following record.

{
            "assetProps": {
                "contentSha1": "202301b9931ab907ac83383fb663ed34cadf0dcf",
                "assetType": "raw",
                "path": "b7eef4ed-0b61-4662-873b-8f323d68af59",
                "originalPath": "",
                "configPath": "",
                "thumbnailPath": "fc563bec-3fa2-441d-aaac-7f56ecbc2e7a"
            },
            "tagProps": {
                "conditions": [],
                "objects": [
                    "car"
                ],
                "other": [
                    "VaticVideos",
                    "1 car"
                ],
                "scenes": [],
                "useCases": []
            },
            "videoProps": {
                "bitrate": 1569731,
                "datetime": "2016-12-25T00:00:00.000",
                "duration": 44000,
                "framerate": 1,
                "height": 720,
                "width": 1280,
                "daySegments": "",
                "overlaysOn": false
            },
            "ext": "ts",
            "uploadTime": "2017-10-27T12:24:03.784-07:00",
            "channel": "1",
            "configProps": {
                "events": []
            },
            "format": "application/octet-stream",
            "fovProps": {
                "width": 0
            },
            "locationProps": {
                "location": {
                    "lat": 0,
                    "lon": 0
                },
                "address": "",
                "city": "USA",
                "state": "",
                "country": "Timelapse",
                "postcode": ""
            },
            "nodeid": "AcuityConyers",
            "poleHeight": 0,
            "retentionPolicy": "Silver",
            "title": "Sensity_Timelapse_USA_AcuityConyers_N02c0113e-1225160000-1_ParkingLot.ts"
        }

(Mayya Sharipova) #2

You can use Bool Query here:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

For example, to find documents for channel = 1 AND ( objects = car OR objects = truck ), and provided that each clause can be expressed as a term query, you can get the following ES query:

{
  "query": {
    "bool" : {
      "must" : {
        "term" : { "channel" : 1 },
        "should" : [
          { "term" : { "objects" : "car" } },
          { "term" : { "objects" : "truck" } }
        ]
      }
    } 
  }
}

(system) #3

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