Help with nested type


(Mohit Anchlia) #1

I am trying to do nested type search. I have 2 documents and mapping listed
below. But it doesn't seem to work. Am I querying it correctly?

Query that failes with no handler found. If I do two/one/_search then it
says "nested" element not found. Not sure how to query it. Could someone
help?

Query:

curl -XGET 'http://dslg1:9200/two/_search' -d '{
"nested" : {
"path" : "one",
"score_mode" : "avg",
"query" : {
"bool" : {
"must" : [
{
"text" : {"attributes.name" : "age"}
},
{
"text" : {"attributes.value" : "3"}
},
]
}
}
}
}'

Mapping:

curl -XPOST 'http://dslg1:9200/two/' -d '{
"mappings" : {
"one" : {
"properties" : {
"attributes" : {
"type" : "nested"
}
}
}
}
}'

doc 1

{ "attributes" : [
{ "base64" : true,
"encrypted" : true,
"name" : "ssn",
"value" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="
},
{ "base64" : false,
"encrypted" : false,
"name" : "deviceId",
"value" : "aass11234aaaxxxCC"
},
{ "base64" : false,
"encrypted" : false,
"name" : "age",
"value" : "1"
}
],
}

doc 2

{ "attributes" : [
{ "base64" : true,
"encrypted" : true,
"name" : "ssn",
"value" : "EAAgfyaxpzdfcfv9Qexq1WtGvA=="
},
{ "base64" : false,
"encrypted" : false,
"name" : "deviceId",
"value" : "aass11234aaaxxxCC"
},
{ "base64" : false,
"encrypted" : false,
"name" : "age",
"value" : "2"
}
],
"version" : 1337298622093
}


(system) #2