Hello,
Now I'm both curious and confused about this behavior.
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.
Furthermore, the document "_source" : {"foo":{"bar":"baz"}} doesn't
appear with any of the following:
'{"filter":{"exists":{"field":"foo"}}}'
'{"filter":{"exists":{"field":"_all"}}}'
But it appears on this:
'{"filter":{"script":{"script":"_source.foo.bar == "baz""}}}'
So what I understand up to this point is that the document is stored,
but not indexed. That's what you meant, Clint?
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}}}}'
Back to the topic, I think the best thing that can be done here is to
reindex your data, this time passing strings as strings.
Best regards,
Radu
http://sematext.com/ -- Elasticsearch -- Solr -- Lucene
On Thu, Oct 25, 2012 at 11:27 AM, Clinton Gormley clint@traveljury.com wrote:
Hiya
"test" : {
"properties" : {
"foo" : {
"type" : "string"
}
}
}And if you index an unescaped JSON, like this:
curl -XPUT localhost:9200/test/test/111 -d '{"foo":{"bar":"baz"}}'
You should end up only with the words, like this:
"_source" : {"foo":"bar baz"}
This wouldn't work. ES receives field 'foo' which is of type 'object',
compares it to the mapping and finds that field 'foo' should be of type
'string', so it ignores it.If you want the bar/baz json to be indexed as text, then you need to
pass it as text:curl -XPOST 'http://127.0.0.1:9200/test/test?pretty=1' -d '
{
"foo" : "{"bar":"baz"}"
}
'clint
--
--