How to write selector query in cloudant for below cloudant json Data

85 views Asked by At

How to write selector query for below data specially for (payload) in cloudant?

    {
      "_id": "1575370d5a7a4cdcd11c64f9066ed454",
      "_rev": "1-2c8aa9288c2e86aa83cea78299c63dcf",
      "topic": "smart_parking",

How to write selector Query for below data specially for (payload) in cloudant?

      "payload": [
        {
          "smart_parking": [
            {

How to write selector for below JSON response?

              "spots": [
                {
                  "read_time": "Wed Jun 21 11:37:55 2017",
                  "awsDeviceIdentifier": "myiot",
                  "vehicle_Make_Model": "suv-crossover",
                  "model_num_car": "subaru_tribeca",
                  "vehicle_make": "subaru",
                  "color": "blue",
                  "time_stamp": 1498045075.780167,
                  "number_plate": "DZDDYXR",
                  "type": "car",
                  "occupied": true
                }
              ]
            }
          ]
        }
      ]
    }

//This is sample one

1

There are 1 answers

0
Rajesh Kumar Kanumetta On BEST ANSWER

{ "selector": {

"payload": {
"$elemMatch":{
  "smart_parking": {
  "$elemMatch":{
    "spots":{
    "$or":[
      {
     "$elemMatch":{"number_plate":"DZDDYXR"} 
     },
     {
     "$elemMatch":{"color":"blue"}
     }
     ]
     }

  }
   }  

  }
}

}, "fields": [

] }