Querying "Hash" Values Stored under String Mapping

Hi Clinton,

On Thu, Oct 25, 2012 at 12:26 PM, Clinton Gormley clint@traveljury.com wrote:

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'.

Neah, I checked through the history and I didn't do that. Plus, it
couldn't have ended up as "foo": "bar baz" if I did that, right?

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.

I was suspecting that. Thanks for confirming :slight_smile:

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

--