# PairRDD.saveToEsWithMeta Object not found

**URL:** <https://discuss.elastic.co/t/pairrdd-savetoeswithmeta-object-not-found/44486>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [March 15, 2016, 7:47pm UTC](https://discuss.elastic.co/t/pairrdd-savetoeswithmeta-object-not-found/44486 "2016-03-15T19:47:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhendric98](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jhendric98](https://discuss.elastic.co/u/jhendric98)\
**Post date:** [March 15, 2016, 7:47pm UTC](https://discuss.elastic.co/t/pairrdd-savetoeswithmeta-object-not-found/44486/1 "2016-03-15T19:47:17Z")

</div>

I am attempting your example in the Spark support for Elasticsearch document page.

[https://www.elastic.co/guide/en/elasticsearch/hadoop/master/spark.html](https://www.elastic.co/guide/en/elasticsearch/hadoop/master/spark.html)

import org.elasticsearch.spark.rdd.Metadata.\_

val otp = Map("iata" -\> "OTP", "name" -\> "Otopeni")  
val muc = Map("iata" -\> "MUC", "name" -\> "Munich")  
val sfo = Map("iata" -\> "SFO", "name" -\> "San Fran")

// metadata for each document  
// note it's not required for them to have the same structure  
val otpMeta = Map(ID -\> 1, TTL -\> "3h")  
val mucMeta = Map(ID -\> 2, VERSION -\> "23")  
val sfoMeta = Map(ID -\> 3)

// instance of SparkContext  
val sc = ...

val airportsRDD = sc.makeRDD(Seq((otpMeta, otp), (mucMeta, muc), (sfoMeta, sfo)))  
pairRDD.saveToEsWithMeta(airportsRDD, "airports/2015")

I cannot get it to compile as the pairRDD object is not found

[error] /testspark/src/main/scala/testspark.scala:43: not found: value PairRDD  
[error] PairRDD.saveToEsWithMeta(airportsRDD, "airports/2015")  
[error] ^  
[error] one error found  
[error] (compile:compileIncremental) Compilation failed  
[error] Total time: 31 s, completed Mar 15, 2016 3:44:46 PM

I'm using sbt and here is my file:

name := "testspark"

version := "1.0"

scalaVersion := "2.10.6"

libraryDependencies += "org.elasticsearch" % "elasticsearch-spark\_2.10" % "2.2.0"  
libraryDependencies += "org.apache.spark" % "spark-core\_2.10" % "1.6.0"

I've also tried spark 1.5.2 with same results.

note: I do have a spark context defined that I've used for your other earlier examples.

I must be missing something somewhere I'm sure.

Thanks,

---

<div class="post-metadata">

**Author:** ![jhendric98](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jhendric98](https://discuss.elastic.co/u/jhendric98)\
**Post date:** [March 15, 2016, 8:32pm UTC](https://discuss.elastic.co/t/pairrdd-savetoeswithmeta-object-not-found/44486/2 "2016-03-15T20:32:30Z")

</div>

Well, an update to this issue. I was able to use the EsSpark class to make the example run successfully.

...

val otp = Map("iata" -\> "OTP", "name" -\> "Otopeni")  
val muc = Map("iata" -\> "MUC", "name" -\> "Munich")  
val sfo = Map("iata" -\> "SFO", "name" -\> "San Fran")

```
// metadata for each document
// note it's not required for them to have the same structure
val otpMeta = Map(ID -> 1, TTL -> "3h")
val mucMeta = Map(ID -> 2, VERSION -> "23")
val sfoMeta = Map(ID -> 3)

val airportsRDD = sc.makeRDD(Seq((otpMeta, otp), (mucMeta, muc), (sfoMeta, sfo)))

```

**EsSpark**.saveToEsWithMeta(airportsRDD, "airports/2015")

Not sure if this is correct, but it works. The documentation could be improved a bit.

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [March 21, 2016, 10:21am UTC](https://discuss.elastic.co/t/pairrdd-savetoeswithmeta-object-not-found/44486/3 "2016-03-21T10:21:10Z")

</div>

Sorry for the typo. Besides using `EsSpark` you could have just used  
`airportsRDD.saveToES` which works as long as one has the `import org.elasticsearch.spark._` specified.

---

<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:** [July 6, 2017, 1:25pm UTC](https://discuss.elastic.co/t/pairrdd-savetoeswithmeta-object-not-found/44486/4 "2017-07-06T13:25:40Z")

</div>


