title: Query with pyspark an Elasticsearch index: how to specify es.nodes?
body: <p>I'm trying to query with pyspark an Elasticsearch index but without success:</p>
  
  <pre><code>] ./bin/pyspark --driver-class-path=jars/elasticsearch-hadoop-2.2.0.jar
  </code></pre>
  
  <p>In ipython, spark version 2.0.1:</p>
  
  <pre><code>In [1]: es_read_conf = { "es.resource" : "test/docs" , "es.nodes" : ["xx.xx.xx.aa","xx.xx.xx.bb","xx.xx.xx.cc"],"es.port" : "9200", "es.net.http.auth.user": "myusername", "es.net.http.auth.pass": "mypassword"}
  es_rdd = sc.newAPIHadoopRDD(inputFormatClass="org.elasticsearch.hadoop.mr.EsInputFormat",keyClass="org.apache.hadoop.io.NullWritable", valueClass="org.elasticsearch.hadoop.mr.LinkedMapWritable", conf=es_read_conf)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.newAPIHadoopRDD.
  : java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
  </code></pre>
  
  <p>It seems that there's a problem converting the python list of es.nodes into a Java string. I tried with a string consisting only of the address of my elasticsearch master node ("xx.xx.xx.aa") but I get another error:</p>
  
  <pre><code>Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.newAPIHadoopRDD.
  : org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: [HEAD] on [test/docs] failed; server[xx.xx.xx.bb:9202] returned [502|Bad Gateway:]
  </code></pre>
  
  <p>Sometimes the error refers to data node bb, sometimes to cc. Interestingly, if I run the same command multiple times, it happens that I get no error (maybe it's when the query is run only against the master node?). I have no problem running the command with localhost as the only es.nodes.</p>