# Python returns arrays after upgrading to ES 1.0

**URL:** <https://discuss.elastic.co/t/python-returns-arrays-after-upgrading-to-es-1-0/15777>\
**Category:** Elasticsearch\
**Created:** [February 13, 2014, 2:11pm UTC](https://discuss.elastic.co/t/python-returns-arrays-after-upgrading-to-es-1-0/15777 "2014-02-13T14:11:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![G\_Kerekes](https://avatars.discourse-cdn.com/v4/letter/g/ee7513/32.png) [@G\_Kerekes](https://discuss.elastic.co/u/G_Kerekes)\
**Post date:** [February 13, 2014, 2:11pm UTC](https://discuss.elastic.co/t/python-returns-arrays-after-upgrading-to-es-1-0/15777/1 "2014-02-13T14:11:18Z")

</div>

We have just upgraded to 1.0 and when I run my previous queries in Python  
(es.search()) I get back the dictionary values in squared brackets:

{u'\_score': 1.0, u'\_type': u'primary', u'\_id': u'21792407', u'fields':  
{u'outletstat': [u'Yes'], u'responseid': [u'21792407'], u'handling':  
[u'Non-Handler'], u'response\_modified': [u'2013-09-17 16:31:30'], u'lgai':  
[u'Ikeja'], u'intid': [u'01133366']}, u'\_index': u'log\_data\_all'}

Anyone experienced the same?

Thanks,  
Geza

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/02835ab0-78ba-41f9-9ea0-f51918729a96%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/02835ab0-78ba-41f9-9ea0-f51918729a96%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Honza\_Kral](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/honza_kral/32/876_2.png) [@Honza\_Kral](https://discuss.elastic.co/u/Honza_Kral)\
**Post date:** [February 13, 2014, 2:17pm UTC](https://discuss.elastic.co/t/python-returns-arrays-after-upgrading-to-es-1-0/15777/2 "2014-02-13T14:17:37Z")

</div>

Hi Geza,

yes, this is correct behavior for elasticsearch now - since it wasn't  
consistent before (sometimes you'd get back values, sometimes lists)  
we changed it to be safe always (always return lists). This is not a  
python-specific change, this is the difference in es output format.

If you're upgrading to 1.0 consider switching over to source filtering  
instead of specifying fields, might look better to you:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Honza

On Thu, Feb 13, 2014 at 3:11 PM, G Kerekes [kerekesg@gmail.com](mailto:kerekesg@gmail.com) wrote:

> We have just upgraded to 1.0 and when I run my previous queries in Python  
> (es.search()) I get back the dictionary values in squared brackets:
> 
> {u'\_score': 1.0, u'\_type': u'primary', u'\_id': u'21792407', u'fields':  
> {u'outletstat': [u'Yes'], u'responseid': [u'21792407'], u'handling':  
> [u'Non-Handler'], u'response\_modified': [u'2013-09-17 16:31:30'], u'lgai':  
> [u'Ikeja'], u'intid': [u'01133366']}, u'\_index': u'log\_data\_all'}
> 
> Anyone experienced the same?
> 
> Thanks,  
> Geza
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/02835ab0-78ba-41f9-9ea0-f51918729a96%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/02835ab0-78ba-41f9-9ea0-f51918729a96%40googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABfdDirKzUdW%2BqBOKPpYBPvG8jJPr7XkhJ52vah3usGnOhqAiw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABfdDirKzUdW%2BqBOKPpYBPvG8jJPr7XkhJ52vah3usGnOhqAiw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![G\_Kerekes](https://avatars.discourse-cdn.com/v4/letter/g/ee7513/32.png) [@G\_Kerekes](https://discuss.elastic.co/u/G_Kerekes)\
**Post date:** [February 13, 2014, 2:38pm UTC](https://discuss.elastic.co/t/python-returns-arrays-after-upgrading-to-es-1-0/15777/3 "2014-02-13T14:38:47Z")

</div>

Hi Honza,

Thanks, make sense, it will be an easy change to make my code working.  
Just to clarify, I would expect the squared brackets when I query from  
browser or from Sense too, but the output look the same as in the previous  
ES versions (no squared brackets):

"hits" : {  
"total" : 84779,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "tns\_log\_data\_all",  
"\_type" : "21792162",  
"\_id" : "primary",  
"\_score" : 1.0, "\_source" : {"gps1": "6.4430759145232;3.3731560125946416;4.0;26.0;4.0;1", "cosmetic\_\_\_drug": "", "file": "DestinationQC22 27-09-2013 10-49-21.xlsx.txt", "response\_revision": "2", "nresponsename": "", "ontrade": "", "projectid": "1011286", "handling": "Non-Handler", "contactnum": "08038473333", "response\_externalid": "", "response\_received": "2013-09-25 16:40:05", "narea": "", "result": "Outllet could not be located/Not found/Not exist at all", "e\_\_telecoms": "", "response\_state": "COMPLETED", "lng": 3.373156, "outname": "", "nwlgai": "Apapa", "area": "wharf", "resultdum\_outlet\_closed\_locked": "FALSE", "outletname": "", "project\_revision": "3", "platform\_version": "2.3.6", "responseid": "22112275", "surveycode": "", "int\_flag": false, "lgai": "Apapa", "taskid": "410327", "other\_category": "", "response\_elapsed": "230", "handling2": "", "offtrade": "", "user\_name": "wa0389", "channel": "", "resultdum\_outlet\_moved\_demolished\_reloca": "FALSE", "pcat\_none1": "", "specialist": "", "club\_institution": "", "user\_externalid": "", "resultdum\_outllet\_could\_not\_be\_located\_n": "TRUE", "response\_name": "", "intid": "01134717", "areachk": "Yes", "response\_created": "2013-09-23 08:15:17", "outletstat": "No", "response\_modified": "2013-09-25 16:39:00", "horeca": "", "address": "eleganza plaxa by aerofrome road", "pcat\_beer": "", "response\_mode": "LIVE", "platform\_model": "GT-S5300", "pcat\_spirit": "", "pcat\_wine": "", "grocery": "", "app\_version": "3.0.3", "lat": 6.443076, "lat\_lng\_accuracy": 4.0, "lgachk": "", "drinks\_venues": "", "ncontactad": "", "comment1": "not existed", "respondentidd": "13145736", "pics": "Click to view", "platform\_name": "android", "convenience": "", "pcat\_carbonated\_soft\_drink": "", "response\_comment": "", "responsename": "Mama chinasa", "pcat\_malt": "", "resultdum\_outlet\_confirmed\_but\_contact\_d": "FALSE", "resultdum\_outlet\_confirmed\_with\_all\_info": "FALSE", "supid": "01120041", "ncontactphn": ""}  
}

That's why I thought I was doing something wrong in Python.

Many thanks,  
Geza

On Thursday, February 13, 2014 2:17:37 PM UTC, Honza Král wrote:

> Hi Geza,
> 
> yes, this is correct behavior for elasticsearch now - since it wasn't  
> consistent before (sometimes you'd get back values, sometimes lists)  
> we changed it to be safe always (always return lists). This is not a  
> python-specific change, this is the difference in es output format.
> 
> If you're upgrading to 1.0 consider switching over to source filtering  
> instead of specifying fields, might look better to you:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-source-filtering.html)
> 
> Honza
> 
> On Thu, Feb 13, 2014 at 3:11 PM, G Kerekes \<[kere...@gmail.com](mailto:kere...@gmail.com)\<javascript:\>\>  
> wrote:
> 
> > We have just upgraded to 1.0 and when I run my previous queries in  
> > Python  
> > (es.search()) I get back the dictionary values in squared brackets:
> > 
> > {u'\_score': 1.0, u'\_type': u'primary', u'\_id': u'21792407', u'fields':  
> > {u'outletstat': [u'Yes'], u'responseid': [u'21792407'], u'handling':  
> > [u'Non-Handler'], u'response\_modified': [u'2013-09-17 16:31:30'],  
> > u'lgai':  
> > [u'Ikeja'], u'intid': [u'01133366']}, u'\_index': u'log\_data\_all'}
> > 
> > Anyone experienced the same?
> > 
> > Thanks,  
> > Geza
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/02835ab0-78ba-41f9-9ea0-f51918729a96%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/02835ab0-78ba-41f9-9ea0-f51918729a96%40googlegroups.com).
> 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/18830359-53ae-4f28-9702-cda9e41016ca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/18830359-53ae-4f28-9702-cda9e41016ca%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Honza\_Kral](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/honza_kral/32/876_2.png) [@Honza\_Kral](https://discuss.elastic.co/u/Honza_Kral)\
**Post date:** [February 13, 2014, 11:18pm UTC](https://discuss.elastic.co/t/python-returns-arrays-after-upgrading-to-es-1-0/15777/4 "2014-02-13T23:18:39Z")

</div>

Hi Geza,

if you request \_source (default) you will get back what was in the  
source when you indexed the document, the same as when you use source  
filtering. If you, however, use fields to specify what you want  
returned you will get back lists.

On Thu, Feb 13, 2014 at 3:38 PM, G Kerekes [kerekesg@gmail.com](mailto:kerekesg@gmail.com) wrote:

> Hi Honza,
> 
> Thanks, make sense, it will be an easy change to make my code working.  
> Just to clarify, I would expect the squared brackets when I query from  
> browser or from Sense too, but the output look the same as in the previous  
> ES versions (no squared brackets):
> 
> "hits" : {  
> "total" : 84779,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "tns\_log\_data\_all",  
> "\_type" : "21792162",  
> "\_id" : "primary",  
> "\_score" : 1.0, "\_source" : {"gps1":  
> "6.4430759145232;3.3731560125946416;4.0;26.0;4.0;1", "cosmetic\_\_\_drug": "",  
> "file": "DestinationQC22 27-09-2013 10-49-21.xlsx.txt", "response\_revision":  
> "2", "nresponsename": "", "ontrade": "", "projectid": "1011286", "handling":  
> "Non-Handler", "contactnum": "08038473333", "response\_externalid": "",  
> "response\_received": "2013-09-25 16:40:05", "narea": "", "result": "Outllet  
> could not be located/Not found/Not exist at all", "e\_\_telecoms": "",  
> "response\_state": "COMPLETED", "lng": 3.373156, "outname": "", "nwlgai":  
> "Apapa", "area": "wharf", "resultdum\_outlet\_closed\_locked": "FALSE",  
> "outletname": "", "project\_revision": "3", "platform\_version": "2.3.6",  
> "responseid": "22112275", "surveycode": "", "int\_flag": false, "lgai":  
> "Apapa", "taskid": "410327", "other\_category": "", "response\_elapsed":  
> "230", "handling2": "", "offtrade": "", "user\_name": "wa0389", "channel":  
> "", "resultdum\_outlet\_moved\_demolished\_reloca": "FALSE", "pcat\_none1": "",  
> "specialist": "", "club\_institution": "", "user\_externalid": "",  
> "resultdum\_outllet\_could\_not\_be\_located\_n": "TRUE", "response\_name": "",  
> "intid": "01134717", "areachk": "Yes", "response\_created": "2013-09-23  
> 08:15:17", "outletstat": "No", "response\_modified": "2013-09-25 16:39:00",  
> "horeca": "", "address": "eleganza plaxa by aerofrome road", "pcat\_beer":  
> "", "response\_mode": "LIVE", "platform\_model": "GT-S5300", "pcat\_spirit":  
> "", "pcat\_wine": "", "grocery": "", "app\_version": "3.0.3", "lat": 6.443076,  
> "lat\_lng\_accuracy": 4.0, "lgachk": "", "drinks\_venues": "", "ncontactad":  
> "", "comment1": "not existed", "respondentidd": "13145736", "pics": "Click  
> to view", "platform\_name": "android", "convenience": "",  
> "pcat\_carbonated\_soft\_drink": "", "response\_comment": "", "responsename":  
> "Mama chinasa", "pcat\_malt": "", "resultdum\_outlet\_confirmed\_but\_contact\_d":  
> "FALSE", "resultdum\_outlet\_confirmed\_with\_all\_info": "FALSE", "supid":  
> "01120041", "ncontactphn": ""}  
> }
> 
> That's why I thought I was doing something wrong in Python.
> 
> Many thanks,  
> Geza
> 
> On Thursday, February 13, 2014 2:17:37 PM UTC, Honza Král wrote:
> 
> > Hi Geza,
> > 
> > yes, this is correct behavior for elasticsearch now - since it wasn't  
> > consistent before (sometimes you'd get back values, sometimes lists)  
> > we changed it to be safe always (always return lists). This is not a  
> > python-specific change, this is the difference in es output format.
> > 
> > If you're upgrading to 1.0 consider switching over to source filtering  
> > instead of specifying fields, might look better to you:
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-source-filtering.html)
> > 
> > Honza
> > 
> > On Thu, Feb 13, 2014 at 3:11 PM, G Kerekes [kere...@gmail.com](mailto:kere...@gmail.com) wrote:
> > 
> > > We have just upgraded to 1.0 and when I run my previous queries in  
> > > Python  
> > > (es.search()) I get back the dictionary values in squared brackets:
> > > 
> > > {u'\_score': 1.0, u'\_type': u'primary', u'\_id': u'21792407', u'fields':  
> > > {u'outletstat': [u'Yes'], u'responseid': [u'21792407'], u'handling':  
> > > [u'Non-Handler'], u'response\_modified': [u'2013-09-17 16:31:30'],  
> > > u'lgai':  
> > > [u'Ikeja'], u'intid': [u'01133366']}, u'\_index': u'log\_data\_all'}
> > > 
> > > Anyone experienced the same?
> > > 
> > > Thanks,  
> > > Geza
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit
> > > 
> > > [https://groups.google.com/d/msgid/elasticsearch/02835ab0-78ba-41f9-9ea0-f51918729a96%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/02835ab0-78ba-41f9-9ea0-f51918729a96%40googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/18830359-53ae-4f28-9702-cda9e41016ca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/18830359-53ae-4f28-9702-cda9e41016ca%40googlegroups.com).
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABfdDio9v%3DbednKQK\_-gnLMChTStpdOd7cdSeKs4OxGkW7tq0Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABfdDio9v%3DbednKQK_-gnLMChTStpdOd7cdSeKs4OxGkW7tq0Q%40mail.gmail.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, 1:50am UTC](https://discuss.elastic.co/t/python-returns-arrays-after-upgrading-to-es-1-0/15777/5 "2017-07-06T01:50:20Z")

</div>


