Problems with nested fields with the same names


(butlermh) #1

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


(Shay Banon) #2

Thats because the actual name of the field when its indexed for the inner fields is "tracks.title", not title, and you search for something that would match it.

If you want all the those fields to be indexed as title, without prefixing it with the objects path, then you can set the path in the object mapping level of tracks: http://www.elasticsearch.org/guide/reference/mapping/object-type.html.

-shay.banon
On Thursday, May 19, 2011 at 9:06 PM, Mark Butler wrote:
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


(butlermh) #3

Thanks Shay.

I change my query

curl -XGET http://localhost:9200/music/album/_search/?q=tracks.title:blinded

RESPONSE:

{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.26010898,"hits":[{"_index":"music","_type":"album","_id":"1","_score":0.26010898,
"_source" : { "title":"Best of Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}}]}}

That works. Good.

Now I create a template using object mapping:

curl -XPUT http://localhost:9200/music/album/_mapping -d '{"album":
{"properties": {"tracks": {"type" : "object","path" :
"just_name","properties" : {"title" : {"type" : "string", "index_name"
: "title"} } } } } }'

RESPONSE:
{"ok":true,"acknowledged":true}

and now try the original query:

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":0,"max_score":null,"hits":[]}}

But it still fails. What I am doing wrong in my mapping? Here is the
mapping in pretty print:

{ "album":
{"properties":
{"tracks":
{"type" : "object","
path" : "just_name",
"properties" :
{"title" :
{"type" : "string", "index_name" : "title"} } } } } }

Also, I must confess I am still a little confused, in my previous
email, why does my first query return results?

Kind regards,

Mark

On 19 May 2011 19:19, Shay Banon shay.banon@elasticsearch.com wrote:

Thats because the actual name of the field when its indexed for the inner
fields is "tracks.title", not title, and you search for something that would
match it.
If you want all the those fields to be indexed as title, without prefixing
it with the objects path, then you can set the path in the object mapping
level of
tracks: http://www.elasticsearch.org/guide/reference/mapping/object-type.html.
-shay.banon

On Thursday, May 19, 2011 at 9:06 PM, Mark Butler wrote:

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


(Shay Banon) #4

make sure to set the mapping on a clean index without it being defined before.
On Thursday, May 19, 2011 at 10:42 PM, Mark Butler wrote:

Thanks Shay.

I change my query

curl -XGET http://localhost:9200/music/album/_search/?q=tracks.title:blinded

RESPONSE:

{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.26010898,"hits":[{"_index":"music","_type":"album","_id":"1","_score":0.26010898,
"_source" : { "title":"Best of Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}}]}}

That works. Good.

Now I create a template using object mapping:

curl -XPUT http://localhost:9200/music/album/_mapping -d '{"album":
{"properties": {"tracks": {"type" : "object","path" :
"just_name","properties" : {"title" : {"type" : "string", "index_name"
: "title"} } } } } }'

RESPONSE:
{"ok":true,"acknowledged":true}

and now try the original query:

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":0,"max_score":null,"hits":[]}}

But it still fails. What I am doing wrong in my mapping? Here is the
mapping in pretty print:

{ "album":
{"properties":
{"tracks":
{"type" : "object","
path" : "just_name",
"properties" :
{"title" :
{"type" : "string", "index_name" : "title"} } } } } }

Also, I must confess I am still a little confused, in my previous
email, why does my first query return results?

Kind regards,

Mark

On 19 May 2011 19:19, Shay Banon shay.banon@elasticsearch.com wrote:

Thats because the actual name of the field when its indexed for the inner
fields is "tracks.title", not title, and you search for something that would
match it.
If you want all the those fields to be indexed as title, without prefixing
it with the objects path, then you can set the path in the object mapping
level of
tracks: http://www.elasticsearch.org/guide/reference/mapping/object-type.html.
-shay.banon

On Thursday, May 19, 2011 at 9:06 PM, Mark Butler wrote:

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


(butlermh) #5

Hi Shay,

Sorry - that was the problem. Thanks, especially for replying so promptly.

These commands worked for me:

curl -XDELETE 'http://localhost:9200/music/'

{"ok":true,"acknowledged":true}

curl -XPUT http://localhost:9200/music/

{"ok":true,"acknowledged":true}

curl -XPUT http://localhost:9200/music/album/_mapping -d '{"album":
{"properties": {"tracks": {"type" : "object","path" :
"just_name","properties" : {"title" : {"type" : "string", "index_name"
: "title"} } } } } }'

{"ok":true,"acknowledged":true}

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}]}'

{"ok":true,"_index":"music","_type":"album","_id":"1","_version":1}

curl -XGET http://localhost:9200/music/album/_search/?q=title:blinded

{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.095891505,"hits":[{"_index":"music","_type":"album","_id":"1","_score":0.095891505,
"_source" : { "title":"Best of Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}}]}}

On 19 May 2011 20:43, Shay Banon shay.banon@elasticsearch.com wrote:

make sure to set the mapping on a clean index without it being defined
before.

On Thursday, May 19, 2011 at 10:42 PM, Mark Butler wrote:

Thanks Shay.

I change my query

curl -XGET http://localhost:9200/music/album/_search/?q=tracks.title:blinded

RESPONSE:

{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.26010898,"hits":[{"_index":"music","_type":"album","_id":"1","_score":0.26010898,
"_source" : { "title":"Best of Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}}]}}

That works. Good.

Now I create a template using object mapping:

curl -XPUT http://localhost:9200/music/album/_mapping -d '{"album":
{"properties": {"tracks": {"type" : "object","path" :
"just_name","properties" : {"title" : {"type" : "string", "index_name"
: "title"} } } } } }'

RESPONSE:
{"ok":true,"acknowledged":true}

and now try the original query:

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":0,"max_score":null,"hits":[]}}

But it still fails. What I am doing wrong in my mapping? Here is the
mapping in pretty print:

{ "album":
{"properties":
{"tracks":
{"type" : "object","
path" : "just_name",
"properties" :
{"title" :
{"type" : "string", "index_name" : "title"} } } } } }

Also, I must confess I am still a little confused, in my previous
email, why does my first query return results?

Kind regards,

Mark

On 19 May 2011 19:19, Shay Banon shay.banon@elasticsearch.com wrote:

Thats because the actual name of the field when its indexed for the inner
fields is "tracks.title", not title, and you search for something that would
match it.
If you want all the those fields to be indexed as title, without prefixing
it with the objects path, then you can set the path in the object mapping
level of
tracks: http://www.elasticsearch.org/guide/reference/mapping/object-type.html.
-shay.banon

On Thursday, May 19, 2011 at 9:06 PM, Mark Butler wrote:

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


(Shay Banon) #6

Great, note you can provide the mappings in the create index request, thus not allowing any sneaky document to come between the create index and put mapping API calls.
On Thursday, May 19, 2011 at 11:01 PM, Mark Butler wrote:

Hi Shay,

Sorry - that was the problem. Thanks, especially for replying so promptly.

These commands worked for me:

curl -XDELETE 'http://localhost:9200/music/'

{"ok":true,"acknowledged":true}

curl -XPUT http://localhost:9200/music/

{"ok":true,"acknowledged":true}

curl -XPUT http://localhost:9200/music/album/_mapping -d '{"album":
{"properties": {"tracks": {"type" : "object","path" :
"just_name","properties" : {"title" : {"type" : "string", "index_name"
: "title"} } } } } }'

{"ok":true,"acknowledged":true}

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}]}'

{"ok":true,"_index":"music","_type":"album","_id":"1","_version":1}

curl -XGET http://localhost:9200/music/album/_search/?q=title:blinded

{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.095891505,"hits":[{"_index":"music","_type":"album","_id":"1","_score":0.095891505,
"_source" : { "title":"Best of Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}}]}}

On 19 May 2011 20:43, Shay Banon shay.banon@elasticsearch.com wrote:

make sure to set the mapping on a clean index without it being defined
before.

On Thursday, May 19, 2011 at 10:42 PM, Mark Butler wrote:

Thanks Shay.

I change my query

curl -XGET http://localhost:9200/music/album/_search/?q=tracks.title:blinded

RESPONSE:

{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.26010898,"hits":[{"_index":"music","_type":"album","_id":"1","_score":0.26010898,
"_source" : { "title":"Best of Thomas Dolby", "tracks":
[{"title":"Hyperactive","number":1},{"title":"She blinded me with
science","number":2}]}}]}}

That works. Good.

Now I create a template using object mapping:

curl -XPUT http://localhost:9200/music/album/_mapping -d '{"album":
{"properties": {"tracks": {"type" : "object","path" :
"just_name","properties" : {"title" : {"type" : "string", "index_name"
: "title"} } } } } }'

RESPONSE:
{"ok":true,"acknowledged":true}

and now try the original query:

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":0,"max_score":null,"hits":[]}}

But it still fails. What I am doing wrong in my mapping? Here is the
mapping in pretty print:

{ "album":
{"properties":
{"tracks":
{"type" : "object","
path" : "just_name",
"properties" :
{"title" :
{"type" : "string", "index_name" : "title"} } } } } }

Also, I must confess I am still a little confused, in my previous
email, why does my first query return results?

Kind regards,

Mark

On 19 May 2011 19:19, Shay Banon shay.banon@elasticsearch.com wrote:

Thats because the actual name of the field when its indexed for the inner
fields is "tracks.title", not title, and you search for something that would
match it.
If you want all the those fields to be indexed as title, without prefixing
it with the objects path, then you can set the path in the object mapping
level of
tracks: http://www.elasticsearch.org/guide/reference/mapping/object-type.html.
-shay.banon

On Thursday, May 19, 2011 at 9:06 PM, Mark Butler wrote:

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


(system) #7