# Handling array values while reading from elasticsearch in spark using elasticsearch-spark

**URL:** <https://discuss.elastic.co/t/handling-array-values-while-reading-from-elasticsearch-in-spark-using-elasticsearch-spark/252950>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [October 22, 2020, 7:27am UTC](https://discuss.elastic.co/t/handling-array-values-while-reading-from-elasticsearch-in-spark-using-elasticsearch-spark/252950 "2020-10-22T07:27:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shubham1](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@shubham1](https://discuss.elastic.co/u/shubham1)\
**Post date:** [October 22, 2020, 7:27am UTC](https://discuss.elastic.co/t/handling-array-values-while-reading-from-elasticsearch-in-spark-using-elasticsearch-spark/252950/1 "2020-10-22T07:27:17Z")

</div>

Hi,

I am trying to read from elasticsearch in spark using es-hadoop library. I know while reading from es-hadoop, we need to pass option **es.read.field.as.array.include** as in code `ApacheSpark.sqlContext.read.format("org.elasticsearch.spark.sql").option("es.nodes", "xx.xxx.xxx").option("es.nodes.client.only", false).option("pushdown", true).option("es.read.field.as.array.include", "tags,fields.component,log.flags,ecs,message").load("ds2-hue_error-2020.09.22")`  
to handle fields with array values. But for that we need to know prior which document fields in elasticsearch index contains array and dimension of that array before calling spark read api. Is there any way of knowing which es-hadoop fields need to passed as array, otherwise it will throw error while reading.

Thanks

---

<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:** [November 19, 2020, 7:27am UTC](https://discuss.elastic.co/t/handling-array-values-while-reading-from-elasticsearch-in-spark-using-elasticsearch-spark/252950/2 "2020-11-19T07:27:22Z")

</div>

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