Querying 2 nested objects in an document?

I have a nested document as follows:

{
"Tags" : {
     "key1" : "value1",
     "key2" : "value2",
     "key3" : "value3"
             },
"NameArray" : [ 
     {
     "Name1" : ["Value1", "Value2" , "Value3"],
     "TimeStamp" : "Value"
     },
     {
     "Name2" : ["Value1", "Value2" , "Value3"],
     "TimeStamp" : "Value"
     }
     ]
}

where Tag and NameArray are of type nested.

How do I query for a particular name for a given timestamp with all the Tag values given?

I tried this:

GET index1/type1/_search
{
  "query" : {
    "nested" : {
      "path" : [{"NameArray"},{"Tags"}],
      "query" : {
        "bool" : {
          "must" : [{"match" : {"Tags.key1.keyword": "a"}},
                    {"match" : {"Tags.key2.keyword": "b"}},
                    {"match" : {"Tags.key3.keyword": "c"}}, 
                    {"range" : {"NameArray.TimeStamp" : {"gte":"2010-07-16T10:24:15.795Z","lte":"2015-07-16T10:24:15.795Z"}}}]
        }
      }
    }
   
  }
}

This doesn't work. Where am I going wrong?

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