# Different result for get and search on arrays

**URL:** <https://discuss.elastic.co/t/different-result-for-get-and-search-on-arrays/13149>\
**Category:** Elasticsearch\
**Created:** [August 9, 2013, 1:19pm UTC](https://discuss.elastic.co/t/different-result-for-get-and-search-on-arrays/13149 "2013-08-09T13:19:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [August 9, 2013, 1:19pm UTC](https://discuss.elastic.co/t/different-result-for-get-and-search-on-arrays/13149/1 "2013-08-09T13:19:41Z")

</div>

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](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](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](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](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [August 12, 2013, 2:07pm UTC](https://discuss.elastic.co/t/different-result-for-get-and-search-on-arrays/13149/2 "2013-08-12T14:07:01Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [August 12, 2013, 3:12pm UTC](https://discuss.elastic.co/t/different-result-for-get-and-search-on-arrays/13149/3 "2013-08-12T15:12:31Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:21am UTC](https://discuss.elastic.co/t/different-result-for-get-and-search-on-arrays/13149/4 "2017-07-06T02:21:32Z")

</div>


