# \[Spark\] saveToEs issue

**URL:** <https://discuss.elastic.co/t/spark-savetoes-issue/122283>\
**Category:** Elasticsearch\
**Created:** [March 2, 2018, 2:59pm UTC](https://discuss.elastic.co/t/spark-savetoes-issue/122283 "2018-03-02T14:59:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastienf](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@sebastienf](https://discuss.elastic.co/u/sebastienf)\
**Post date:** [March 2, 2018, 2:59pm UTC](https://discuss.elastic.co/t/spark-savetoes-issue/122283/1 "2018-03-02T14:59:01Z")

</div>

Hi,

Considering the following example :

```
JavaSparkContext jsc = new JavaSparkContext(sparkConf);                             

Map<String, ?> numbers = ImmutableMap.of("one", 1, "two", 2);                   
Map<String, ?> airports = ImmutableMap.of("OTP", "Otopeni", "SFO", "San Fran");

//RDD init >>
JavaRDD<Map<String, ?>> javaRDD = jsc.parallelize(ImmutableList.of(numbers, airports));

```

I noticed that the following line throws an exception "Cluster state volatile; cannot find node backing shards - please check whether your cluster is stable" :

`JavaEsSpark.saveToEs(javaRDD, "testindex/testdoc");`

But when I do this way (dynamic type) :

```
Map<String, ?> numbers = ImmutableMap.of("doc","dummy","one", 1, "two", 2);                   
Map<String, ?> airports = ImmutableMap.of("doc","dummy","OTP", "Otopeni", "SFO", "San Fran");

JavaEsSpark.saveToEs(javaRDD, "testindex/{doc}");

```

... it works !

I don't understand what is going on ?

Thanks for helping me 🙂

---

<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:** [March 30, 2018, 2:59pm UTC](https://discuss.elastic.co/t/spark-savetoes-issue/122283/2 "2018-03-30T14:59:03Z")

</div>

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