Closed
Description
Hello,
I'm trying to save a document on Elasticsearch using Scala and the parameter ES_MAPPING_TIMESTAMP isn't working: I can see my field in my final document on ES but not as @timestamp. Nevertheless, all the other parameters are working.
sparkConf.set(ConfigurationOptions.ES_INDEX_AUTO_CREATE, true)
.set(ConfigurationOptions.ES_NODES_WAN_ONLY, true)
.set(ConfigurationOptions.ES_INPUT_JSON,false)
stream.foreachRDD { rdd =>
if (rdd.count() > 0) {
val event = sqlContext.read.json(rdd.values)
event.saveToEs(Map(ConfigurationOptions.ES_RESOURCE -> "{topic}-{calendardate:YYYY.MM.dd}/log",
ConfigurationOptions.ES_MAPPING_TIMESTAMP -> "calendardate",
ConfigurationOptions.ES_MAPPING_EXCLUDE -> "id",
ConfigurationOptions.ES_MAPPING_ID -> "id"))
}
}
My final document looks like this :
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "xxx-2016.03.18",
"_type": "log",
"_id": "yyy-123",
"_score": 1,
"_source": {
"@timestamp": "2016-05-18T16:39:39.317Z",
"@version": "1",
"foo": "bar",
"topic": "xxx",
"timenow": "2016-05-18T16:39:49.258Z",
"calendardate": "2016-03-18T10:11:28.123Z"
}
}
]
}
}
On the other hand, on Java using JavaEsSpark.saveJsonToEs the parameter ES_MAPPING_TIMESTAMP works, but not the ConfigurationOptions.ES_MAPPING_EXCLUDE ( related to #381)
Version Info
OS: : Windows 7 64 bits/ CentOS
JVM : JDK 1.8
Hadoop/Spark: HDP 2.4 / 1.6.0
ES-Hadoop : 2.3.1
ES : 2.3.1