Different result for get and search on arrays

Hi,

we noticed a strange behavior lately, may be someone can help on this one.
My problem is the following: I am indexing a field, I pass the value as
JsonArray. So far, so good. Problem is when I try to read this document
using fields. To explain it I show you some examples:

curl -XGET http://localhost:9300/picture/picture_object/16084571
{"_index":"picture","_type":"picture_object","_id":"16084571","_version":1,"exists":true,
"_source" : {"URI":"16084571","CATEGORY":[],"MAINCOLORS":["#c0c0c0"]}}

This is the result as expected. Next thing I tried was reading just certain
fields:

curl -XGET
http://localhost:9300/picture/picture_object/16084571?fields=MAINCOLORS,CATEGORY
{"_index":"picture","_type":"picture_object","_id":"16084571","_version":1,"exists":true,"fields":{"MAINCOLORS":"#c0c0c0"}}

Category is not returned, I would have expected an empty array here.
Maincolors became a single element, not an array anymore. If I pick a
document with more than one element in Maincolor it is an array (what
else...).

To make it even worse I tried searching and returning fields:

curl -XGET http://localhost:9300/picture/picture_object/_search -d
'{"query":{"term":{"_id":16084571}},"fields":["CATEGORY","MAINCOLORS"]}'
{"took":2,"timed_out":false,"_shards":{"total":8,"successful":8,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"picture","_type":"picture_object","_id":"16084571","_score":1.0,"fields":{"MAINCOLORS":["#c0c0c0"],"CATEGORY":[]}}]}}

So this is what I would have expected from get also, returning (even empty)
arrays. Is this different behavior between get and search a bug or a
feature?

This test was done on elasticsearch 0.90.2. I compared it with 0.20.2,
there was the result the expected one:

curl -XGET
http://localhost:9300/picture/picture_object/16084571?fields=CATEGORY,PSCORE,MAINCOLORS
{"_index":"picture","_type":"picture_object","_id":"16084571","_version":1,"exists":true,"fields":{"MAINCOLORS":["#c0c0c0"],"CATEGORY":[],"PSCORE":1515}}

So obviously the way fields are returned was changed, still, as it doesnt
return the same for search and get I think this is a bug. The mapping for
these fields is unspectacular btw:

  • MAINCOLORS: {
    • index: not_analyzed
    • omit_norms: true
    • index_options: docs
    • type: string
      }
  • CATEGORY: {
    • type: string
      }

Could someone give me some feedback if this is wanted behavior or not? Or
if it is changed in 0.90.3 may be?

Thanks!
Andrej

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ok, I tried this on 0.90.3, same effect. I dont think search and get should
return different results, therefore I would consider it being a bug. Shall
I open a bugticket for it?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Andrej,
I had a look at your email and reproduced the issue. I agree with you, the
behaviour should be the same between get and search.
It does seem like a bug, so you can definitely go ahead and create an issue
here.

Thanks a lot for reporting this
Luca

On Monday, August 12, 2013 4:07:01 PM UTC+2, Andrej Rosenheinrich wrote:

Ok, I tried this on 0.90.3, same effect. I dont think search and get
should return different results, therefore I would consider it being a bug.
Shall I open a bugticket for it?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.