Hi Shay, Clint, everyone,
I am having some problems with documents that contain nested fields
with the same name as fields in the enclosing document.
Here are some examples.
I create a simple document representing an album:
curl -XPUT http://localhost:9200/music/album/1 -d '{ "album":"Best of
Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}'
RESPONSE:
{"ok":true,"_index":"music","_type":"album","_id":"1","_version":1}
Then I query it
curl -XGET http://localhost:9200/music/album/_search/?q=title:blinded
RESPONSE:
{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.13424811,"hits":[{"_index":"music","_type":"album","_id":"1","_score":0.13424811,
"_source" : { "album":"Best of Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}}]}}
All okay, Good. Now let's try doing the same thing but with the nested
fields using the same name as one in the encompassing object.
curl -XPUT http://localhost:9200/music/album/1 -d '{ "title":"Best of
Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}'
RESPONSE:
{"ok":true,"_index":"music","_type":"album","_id":"1","_version":2}
curl -XGET http://localhost:9200/music/album/_search/?q=title:blinded
RESPONSE:
{"took":6,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
No results? Is this right? Are nested fields with the same name not allowed?
Now for something else strange. I decide to go back to my original
design, put the original version of the document back.
curl -XPUT http://localhost:9200/music/album/1 -d '{ "album":"Best of
Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}'
RESPONSE:
{"ok":true,"_index":"music","_type":"album","_id":"1","_version":3}
curl -XGET http://localhost:9200/music/album/_search/?q=title:blinded
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
Still no results? Why is querying failing now?
I have been working with some quite complicated templates to overcome
this problem, but they do not seem to solve it. This is the simplest
test case I could come up with to demonstrate the behavior.
Best wishes, and thank you for ES!
Mark