# Create Index with Spark adding Dates and Doubles

**URL:** <https://discuss.elastic.co/t/create-index-with-spark-adding-dates-and-doubles/26305>\
**Category:** Elasticsearch\
**Created:** [July 26, 2015, 3:49pm UTC](https://discuss.elastic.co/t/create-index-with-spark-adding-dates-and-doubles/26305 "2015-07-26T15:49:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pferrel](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@pferrel](https://discuss.elastic.co/u/pferrel)\
**Post date:** [July 26, 2015, 3:49pm UTC](https://discuss.elastic.co/t/create-index-with-spark-adding-dates-and-doubles/26305/1 "2015-07-26T15:49:58Z")

</div>

Using Scala I create a complete index in a Spark RDD of Maps then use this in the following form:

```
esFields.saveToEs (esIndexURI, Map("es.mapping.id" -> "id"))

```

Where `esFields` is an RDD of Maps, one element is `("id"->docID)` which is mapped to the Elasticsearch "id". I have no problem adding other strings or arrays of strings to the `_source` or a doc so all is working fine.

Now I want to add other types to the index, like a timestamp and a Double. The date will be used in a date range filtering query. How do I add a date to the index using a Scala Map?

Can I have a `Map[String, Any]` and expect `saveToEs` to determine the types during the save? so the Maps in the RDD would be something like:

```
val m = Map(
  id-> "docID",
  category -> Array("cat1", "cat2"),
  timeStamp -> someDate )

```

If this is correct what type should `someDate` be? I read these as ISO format strings and so can create any Date type needed. I need Elasticsearch to index these as dates so date ranges can be used in the query.

---

<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 5, 2017, 11:58pm UTC](https://discuss.elastic.co/t/create-index-with-spark-adding-dates-and-doubles/26305/2 "2017-07-05T23:58:56Z")

</div>


