Strange (buggy?) behaviour with nested attributes

Hi there,

we are currently playing around with nested attributes and experienced
a strange behaviour when not configuring them in the mapping.

When indexing this JSON document

{
"attrs": {
"foo": "bar"
},
"baz": "ham"
}

and having this mapping configured for the type which defaults to
string for anything:

{
"product": {
"include_in_all": false,
"dynamic_templates" : [
{
"store_generic" : {
"match" : "*",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
],
"properties": {
"ProductId": { "type": "string", "index":
"not_analyzed" }
}
}
}
}

results in not being able to query any fields, which are behind the
"attrs" field, so I cannot do a term query on the field "baz" for
"ham"

When adding the attrs as object in the mapping, it all works fine.
However it just does not work without the configuration and does not
spit any warning. IMO it should ignore the "attrs" attribute then, but
still index the baz attribute correctly.

Bug or feature? :slight_smile:

Thanks & regards,
--Alexander

Once you index, can you do a get mapping to see what the result of it is? I
suspect "attrs" will be of type string (instead of object, which is should
be) because you match on all names. It won't fail during indexing in this
case (I suspect, didn't test it). You can use mach_type set to string to
apply the mentioned logic only on string type fields.

On Wed, Jan 11, 2012 at 7:31 PM, Alexander Reelsen <
alexander.reelsen@googlemail.com> wrote:

Hi there,

we are currently playing around with nested attributes and experienced
a strange behaviour when not configuring them in the mapping.

When indexing this JSON document

{
"attrs": {
"foo": "bar"
},
"baz": "ham"
}

and having this mapping configured for the type which defaults to
string for anything:

{
"product": {
"include_in_all": false,
"dynamic_templates" : [
{
"store_generic" : {
"match" : "*",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
],
"properties": {
"ProductId": { "type": "string", "index":
"not_analyzed" }
}
}
}
}

results in not being able to query any fields, which are behind the
"attrs" field, so I cannot do a term query on the field "baz" for
"ham"

When adding the attrs as object in the mapping, it all works fine.
However it just does not work without the configuration and does not
spit any warning. IMO it should ignore the "attrs" attribute then, but
still index the baz attribute correctly.

Bug or feature? :slight_smile:

Thanks & regards,
--Alexander