# Query Response: Fields in a particular order

**URL:** <https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334>\
**Category:** Elasticsearch\
**Created:** [May 4, 2014, 8:17am UTC](https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334 "2014-05-04T08:17:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shrinidhi\_chaudhari](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@shrinidhi\_chaudhari](https://discuss.elastic.co/u/shrinidhi_chaudhari)\
**Post date:** [May 4, 2014, 8:17am UTC](https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334/1 "2014-05-04T08:17:36Z")

</div>

Is there a way to get a response in which the fields are in a particular  
order?

--  
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/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 4, 2014, 8:26am UTC](https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334/2 "2014-05-04T08:26:37Z")

</div>

Do you mean fields in \_source document?  
Or when using fields parameter when querying?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 mai 2014 à 10:17, shrinidhi chaudhari [shrinidhi.chaudhari@gmail.com](mailto:shrinidhi.chaudhari@gmail.com) a écrit :

## Is there a way to get a response in which the fields are in a particular order?

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/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/2B8A3E97-30DF-42F1-8611-DC7809EC581D%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/2B8A3E97-30DF-42F1-8611-DC7809EC581D%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![shrinidhi\_chaudhari](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@shrinidhi\_chaudhari](https://discuss.elastic.co/u/shrinidhi_chaudhari)\
**Post date:** [May 4, 2014, 8:32am UTC](https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334/3 "2014-05-04T08:32:44Z")

</div>

fields in \_source, such the result given are in a specified order.

On Sunday, 4 May 2014 13:56:37 UTC+5:30, David Pilato wrote:

> Do you mean fields in \_source document?  
> Or when using fields parameter when querying?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 4 mai 2014 à 10:17, shrinidhi chaudhari \<[shrinidhi...@gmail.com](mailto:shrinidhi...@gmail.com)\<javascript:\>\>  
> a écrit :
> 
> Is there a way to get a response in which the fields are in a particular  
> order?
> 
> --  
> 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/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/51dfaae7-901b-4bf2-a2c2-e25599ca0a9a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/51dfaae7-901b-4bf2-a2c2-e25599ca0a9a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![shrinidhi\_chaudhari](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@shrinidhi\_chaudhari](https://discuss.elastic.co/u/shrinidhi_chaudhari)\
**Post date:** [May 4, 2014, 8:36am UTC](https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334/4 "2014-05-04T08:36:41Z")

</div>

_Example_  
The response if specified is "field\_order": ["\_id", "timestamp", "status"].  
Then the response should have the values in that same order as specified in  
"field\_order" parameter.

On Sunday, 4 May 2014 14:02:44 UTC+5:30, shrinidhi chaudhari wrote:

> fields in \_source, such the result given are in a specified order.
> 
> On Sunday, 4 May 2014 13:56:37 UTC+5:30, David Pilato wrote:
> 
> > Do you mean fields in \_source document?  
> > Or when using fields parameter when querying?
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 4 mai 2014 à 10:17, shrinidhi chaudhari [shrinidhi...@gmail.com](mailto:shrinidhi...@gmail.com) a  
> > écrit :
> > 
> > Is there a way to get a response in which the fields are in a particular  
> > order?
> > 
> > --  
> > 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/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/b06e44c1-9529-4940-b8f9-f12d11533785%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b06e44c1-9529-4940-b8f9-f12d11533785%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 4, 2014, 8:46am UTC](https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334/5 "2014-05-04T08:46:28Z")

</div>

Elasticsearch gives you back your \_source document as you sent it with no modification.  
If you want some fields, you need to use: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html#search-request-fields)

I think that fields come back in the same order but I might be wrong. That said, in JSON, order does not matter, right?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 mai 2014 à 10:32, shrinidhi chaudhari [shrinidhi.chaudhari@gmail.com](mailto:shrinidhi.chaudhari@gmail.com) a écrit :

fields in \_source, such the result given are in a specified order.

> On Sunday, 4 May 2014 13:56:37 UTC+5:30, David Pilato wrote:  
> Do you mean fields in \_source document?  
> Or when using fields parameter when querying?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 4 mai 2014 à 10:17, shrinidhi chaudhari [shrinidhi...@gmail.com](mailto:shrinidhi...@gmail.com) a écrit :
> 
> ## Is there a way to get a response in which the fields are in a particular order?
> 
> 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/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/51dfaae7-901b-4bf2-a2c2-e25599ca0a9a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/51dfaae7-901b-4bf2-a2c2-e25599ca0a9a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/A001DA4D-0399-4047-9F13-8F3E8E5FDE38%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/A001DA4D-0399-4047-9F13-8F3E8E5FDE38%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![shrinidhi\_chaudhari](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@shrinidhi\_chaudhari](https://discuss.elastic.co/u/shrinidhi_chaudhari)\
**Post date:** [May 4, 2014, 8:56am UTC](https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334/6 "2014-05-04T08:56:26Z")

</div>

Yes you are right.  
Will have to handle this at the front-end. Since the order is maintained in  
an JSON array, the order will be available there.

On Sunday, 4 May 2014 14:16:28 UTC+5:30, David Pilato wrote:

> Elasticsearch gives you back your \_source document as you sent it with no  
> modification.  
> If you want some fields, you need to use:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html#search-request-fields)
> 
> I think that fields come back in the same order but I might be wrong. That  
> said, in JSON, order does not matter, right?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 4 mai 2014 à 10:32, shrinidhi chaudhari \<[shrinidhi...@gmail.com](mailto:shrinidhi...@gmail.com)\<javascript:\>\>  
> a écrit :
> 
> fields in \_source, such the result given are in a specified order.
> 
> On Sunday, 4 May 2014 13:56:37 UTC+5:30, David Pilato wrote:
> 
> > Do you mean fields in \_source document?  
> > Or when using fields parameter when querying?
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 4 mai 2014 à 10:17, shrinidhi chaudhari [shrinidhi...@gmail.com](mailto:shrinidhi...@gmail.com) a  
> > écrit :
> > 
> > Is there a way to get a response in which the fields are in a particular  
> > order?
> > 
> > --  
> > 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/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/62a93abc-4752-4c57-8b66-151d3dde2af8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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/51dfaae7-901b-4bf2-a2c2-e25599ca0a9a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/51dfaae7-901b-4bf2-a2c2-e25599ca0a9a%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/51dfaae7-901b-4bf2-a2c2-e25599ca0a9a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/51dfaae7-901b-4bf2-a2c2-e25599ca0a9a%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/02c869a6-6fd2-4061-b5fc-45622200f3df%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/02c869a6-6fd2-4061-b5fc-45622200f3df%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:31am UTC](https://discuss.elastic.co/t/query-response-fields-in-a-particular-order/17334/7 "2017-07-06T01:31:55Z")

</div>


