anchor.diff:          .map(p => Person(p(0), p(1), p(2).trim.toInt))
   
   
  -people.saveToEs("spark/people")          <4>
  +people.saveToEs("spark/people")           <4>
   ----
   
   <1> Spark SQL package import
  
positive.code: <2> {eh} Java imports
  <3> start Spark through its Java API
  <4> to simplify the example, use https://code.google.com/p/guava-libraries/[Guava](a dependency of Spark) +Immutable+* methods for simple +Map+, +List+ creation
  <5> create a simple +RDD+ over the two collections; any other RDD (in Java or Scala) can be passed in
  <6> index the content (namely the two _documents_ (numbers and airports)) in {es} under `spark/docs`
  
  The code can be further simplifies by using Java 5 _static_ imports, namely:
  
  [source,java]
  ----
  import static org.elasticsearch.spark.java.api.JavaEsSpark; <1>
  ...
  saveToEs(javaRDD, "spark/docs"); <2>
  ----
  
  <1> statically import +JavaEsSpark+
  <2> call +saveToEs+ method without having to type +JavaEsSpark+ again
  
  
  Setting the document id (or other metadata fields like +ttl+ or +timestamp+) is similar to its Scala counterpart though potentially bit more verbose depending on whether you are using the JDK classes or some other utilities (like Guava):
  
negative.code: ----
  EsSpark.saveToEs(rdd, "spark/docs", Map("es.mapping.id" -> "id"))
  ----
  
  .Java
  
  