title: Spark fails to parse field from elasticsearch
body: <p>I`m trying to read data from ElasticSearch to Spark using Scala.
  The problematic field in elasticsearch is defined as object.
  When I tried without schema got an empty object, with schema getting an exception.</p>
  <p>Object in ES looks like</p>
  <pre><code>{
   &quot;field1&quot; : &quot;value1&quot;,
   &quot;field2&quot; : &quot;value2&quot;,
   &quot;field3&quot; : &quot;value&quot;,
   &quot;field4&quot; : true,
   &quot;field5&quot; : true,
   &quot;field6&quot; : true,
   &quot;field7&quot; : &quot;value7&quot;,
   &quot;field8&quot; : &quot;value8&quot;,
   &quot;field9&quot; : &quot;value9&quot;,
   &quot;field10&quot; : &quot;value10&quot;
  },
  ...
  ,
  {
   &quot;field1&quot; : &quot;value1&quot;,
   &quot;field2&quot; : &quot;value2&quot;,
   &quot;field3&quot; : &quot;value&quot;,
   &quot;field4&quot; : true,
   &quot;field5&quot; : true,
   &quot;field6&quot; : true,
   &quot;field7&quot; : &quot;value7&quot;,
   &quot;field8&quot; : &quot;value8&quot;,
   &quot;field9&quot; : &quot;value9&quot;,
   &quot;field10&quot; : &quot;value10&quot;
  }
  </code></pre>
  <p>I tried a lot of different options. For example:</p>
  <pre><code> case class Element(
                             field1: String,
                             field2: String,
                             field3: String,
                             field4: Boolean,
                             field5: Boolean,
                             field6: Boolean,
                             field7: String,
                             field8: String,
                             field9: String,
                             field10: String
                           )
  
    case class Elements(innerElement: Array[Element])
    val elementsSchema = ScalaReflection.schemaFor[Elements].dataType.asInstanceOf[StructType]
    val customSchema = StructType(Array(
      StructField(&quot;docField1&quot;, StringType, true),
      StructField(&quot;docField2&quot;, StringType, true),
      ...
      StructField(&quot;docField20&quot;, elementsSchema, true),
      StructField(&quot;docField21&quot;, StringType, true)
    ))
  </code></pre>
  <p>Exception:</p>
  <pre><code>Caused by: java.lang.RuntimeException: scala.collection.convert.Wrappers$JListWrapper is not a valid external type for schema of struct&lt;Element:array&lt;struct&lt;field1:string,field2:string,field3:string,field4:boolean,field5:boolean,field6:boolean,field7:string,field8:string,field9:string,field10:string&gt;&gt;&gt;
  </code></pre>
  <p>Tried with <code>.option(&quot;es.read.field.as.array.include&quot;, &quot;elements&quot;)</code></p>
  <p>Tried to use different API <code>spark.read.format(&quot;org.elasticsearch.spark.sql&quot;)</code> and <code>sc.esRDD</code></p>
  <p>I would like some advice, thanks.</p>