# Elastic search array value

**URL:** <https://discuss.elastic.co/t/elastic-search-array-value/358260>\
**Category:** Elasticsearch\
**Created:** [April 26, 2024, 5:26am UTC](https://discuss.elastic.co/t/elastic-search-array-value/358260 "2024-04-26T05:26:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_Kit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/j_kit/32/77810_2.png) [@J\_Kit](https://discuss.elastic.co/u/J_Kit)\
**Post date:** [April 26, 2024, 5:26am UTC](https://discuss.elastic.co/t/elastic-search-array-value/358260/1 "2024-04-26T05:26:47Z")

</div>

Hi

Woud like to ask for advice on array type value  
Example, I got my index mapping for this field

author: {  
type: integer  
}

and when we store the value we would like to store as array as might contain 1 or more

Example

author: [1, 2, 3]

**my question is if we got just 1 value, do we store as a) or b)**

a) author: 1  
b) author: [1]

we looking to store as array [1] as standard array value to use for **search, filter and aggregation.** is there standard that we should store as author:1 that im not aware of? or array should be good enough

**Other values we store as below:**

for multiple value, we store as  
author:[1,2,3]

and if empty, we store as  
author:

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [April 26, 2024, 4:32pm UTC](https://discuss.elastic.co/t/elastic-search-array-value/358260/2 "2024-04-26T16:32:28Z")

</div>

In my opinion, if you are dealing with arrays, you should index only arrays. Therefore, option B would be the ideal choice if there were only one element in the array.

This helps maintain consistency in documents. Imagine the effort required to determine whether document A or B has field X as an array or not. Additionally, when working with scripts, you don't need to check whether the field is an array or not.

I recommend reading this document, which may be helpful: [Arrays | Elasticsearch Guide [8.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html)
