Querying "Hash" Values Stored under String Mapping

Hi Radu

So yesterday I tested before writing here what's described below and
it worked. I just copy-pasted here. Now, I can't reproduce the same
behavior (went through the history - I still don't get it). Instead, I
get what govind201 reported. I was using 0.19.11 all this time.

I think you probably deleted the index then indexed the doc, which
created a mapping for the 'foo' field of type 'object'.

Furthermore, the document "_source" : {"foo":{"bar":"baz"}} doesn't
appear with any of the following:

'{"filter":{"exists":{"field":"foo"}}}'
'{"filter":{"exists":{"field":"_all"}}}'

Correct. Because the {bar:baz} value for foo is ignored, the 'foo'
field is "missing", and similarly, no values have been passed to '_all',
so that is also "missing".

But it appears on this:

'{"filter":{"script":{"script":"_source.foo.bar == "baz""}}}'

The _source field just returns whatever JSON doc you passed to
elasticsearch. It has nothing to do with what is indexed.

So what I understand up to this point is that the document is stored,
but not indexed. That's what you meant, Clint?

Correct

That said, it seems to be fine if I throw in an integer there instead
of a string:

curl -XPUT localhost:9200/test/test/111 -d '{"foo":2}'

curl -XPOST localhost:9200/test/test/_search?pretty=true -d '{

"query": { "match": { "foo":2}}}'

curl -XPOST localhost:9200/test/test/_search?pretty=true -d

'{"filter":{"range":{"foo":{"from": 1, "to": 3}}}}'

Yes, value 2 becomes "2" because it is type 'string'. Note, however,
that your range is string based, not number based.

curl -XPOST 'http://127.0.0.1:9200/test/test' -d '{"foo": 2}'
curl -XPOST 'http://127.0.0.1:9200/test/test' -d '{"foo": 20}'
curl -XPOST 'http://127.0.0.1:9200/test/test' -d '{"foo": 3}'

curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d '
{
"query" : {
"range" : {
"foo" : {
"from" : 2,
"to" : 3
}
}
}
}
'

This will return docs '2' and '20' but not '3'

"hits" : [

{

"_source" : {

"foo" : 2

},

"_score" : 1,

"_index" : "test",

"_id" : "SsfC4j-5RpuEPfg4FEPvzQ",

"_type" : "test"

},

{

"_source" : {

"foo" : 20

},

"_score" : 1,

"_index" : "test",

"_id" : "Du9X5JfQSTu4Jljotg8MFw",

"_type" : "test"

}

],

clint

--