# Query having firsts five elements in the array

**URL:** https://discuss.elastic.co/t/query-having-firsts-five-elements-in-the-array/165106
**Category:** Elasticsearch
**Created:** [January 21, 2019, 5:57pm UTC](https://discuss.elastic.co/t/query-having-firsts-five-elements-in-the-array/165106 "2019-01-21T17:57:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![m.fayazahammed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m.fayazahammed/32/68044_2.png) [@m.fayazahammed](https://discuss.elastic.co/u/m.fayazahammed)
#### Post date: [January 21, 2019, 5:57pm UTC](https://discuss.elastic.co/t/query-having-firsts-five-elements-in-the-array/165106/1 "2019-01-21T17:57:22Z")

</div>

Hi,

Do you know any query that can be used to get first five elements in the array of the document if the array has more than 20 elements.

Basically 5 is a parameter and it can vary. please advice on this.

ex: itemID,itemlist : [1,2,3,4,5,6,7,8,9,10,11,12,13,14]

expected:  
itemID, itemlist:[1,2,3,4,5]

---

<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: [January 21, 2019, 6:10pm UTC](https://discuss.elastic.co/t/query-having-firsts-five-elements-in-the-array/165106/2 "2019-01-21T18:10:18Z")

</div>

Elasticsearch does not really modify the `_source` document. So my guess is that it would be easier to solve that on the client side.

---

<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: [February 18, 2019, 6:10pm UTC](https://discuss.elastic.co/t/query-having-firsts-five-elements-in-the-array/165106/3 "2019-02-18T18:10:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
