bhupesh
(bhupesh)
February 22, 2013, 6:45pm
1
Hey folks,
I am playing with Elasticsearch nested query and see some issue, can
someone please help me explain it.
ES version: 0.20.5 (same behavior in 0.19.5 as well)
The steps to reproduce are here
elasticsearch-nested-test.sh
# Create a new index
curl -XPUT http://localhost:9200/newindex
# Create a nested mapping
curl -XPUT http://localhost:9200/newindex/foo/_mapping -d '{"foo" : {"properties": { "nested_field" : { "type": "nested" }} }}'
# Add a document
curl -XPUT http://localhost:9200/newindex/foo/5812395 -d '{ "nested_field" : [ { "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 } ], "id":5812395 }'
# Refresh the index
This file has been truncated. show original
The question in short is, let say I am indexing a nested field as in
"nested_field" : [ { "name" : "blue", "count" : 4 }, { "name" : "green",
"count" : 6 } ]
when I _search using nested query as
curl -XGET http://localhost:9200/newindex/foo/_search?pretty=true -d
'{ "query" : {"nested" : { "path" : "nested_field", "query": {
"query_string": { "query": "name:blue AND count:4" }}}}}'
I am expecting to get back only matching child part for the nested field as
in { "name" : "blue", "count" : 4 }
But I get back both as in
"nested_field" : [ { "name" : "blue", "count" : 4 }, { "name" : "green",
"count" : 6 } ] (The part with "name": "green" should not show up in my
mind)
Best
Bhupesh
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .
Hi Buphesh
I am expecting to get back only matching child part for the nested
field as in { "name" : "blue", "count" : 4 }
But I get back both as in
"nested_field" : [ { "name" : "blue", "count" : 4 }, { "name" :
"green", "count" : 6 } ] (The part with "name": "green" should not
show up in my mind)
When you run a query, you get back the documents that match, ie the
whole document, not just the parts of it that match.
Currently there is no way to return just the parts, although there is an
issue open to request support for it
clint
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .