# How to update about JavaEsSpark.saveToEs

**URL:** <https://discuss.elastic.co/t/how-to-update-about-javaesspark-savetoes/106279>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [November 3, 2017, 8:09am UTC](https://discuss.elastic.co/t/how-to-update-about-javaesspark-savetoes/106279 "2017-11-03T08:09:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyitclj](https://avatars.discourse-cdn.com/v4/letter/h/cab0a1/32.png) [@hyitclj](https://discuss.elastic.co/u/hyitclj)\
**Post date:** [November 3, 2017, 8:09am UTC](https://discuss.elastic.co/t/how-to-update-about-javaesspark-savetoes/106279/1 "2017-11-03T08:09:37Z")

</div>

Issue description

Description

My test ES data:  
#! Deprecation: query malformed, empty clause found at [2:13]  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "face\_imsi\_test",  
"\_type": "face\_imsi\_test",  
"\_id": "123",  
"\_score": 1,  
"\_source": {  
"img\_id": "11",  
"img\_url": "11",  
"pid": "123",  
"imsis": [  
{  
"imsi114": "10"  
}  
],  
"update\_time": "2017-10-12 19:49:04"  
}  
}  
]  
}  
}

if My new data is "pid:123,imsis{imsi113:10}" I want update or not replace  
I want data as follow:  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "face\_imsi\_test",  
"\_type": "face\_imsi\_test",  
"\_id": "123",  
"\_score": 1,  
"\_source": {  
"img\_id": "11",  
"img\_url": "11",  
"pid": "123",  
"imsis": [  
{  
"imsi114": "10",  
"imsi113": "10"  
}  
],  
"update\_time": "2017-10-12 19:49:04"  
}  
}  
]  
}  
}

if My new data is "pid:123,imsis{imsi114:20}" I want update or not replace  
I want data as follow:  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "face\_imsi\_test",  
"\_type": "face\_imsi\_test",  
"\_id": "123",  
"\_score": 1,  
"\_source": {  
"img\_id": "11",  
"img\_url": "11",  
"pid": "123",  
"imsis": [  
{  
"imsi114": "20",  
"imsi113": "10"  
}  
],  
"update\_time": "2017-10-12 19:49:04"  
}  
}  
]  
}  
}

but now it's replace : My new data is "pid:123,imsis{imsi113:10}"  
the result as follow  
#! Deprecation: query malformed, empty clause found at [2:13]  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "face\_imsi\_test",  
"\_type": "face\_imsi\_test",  
"\_id": "123",  
"\_score": 1,  
"\_source": {  
"img\_id": "11",  
"img\_url": "11",  
"pid": "123",  
"imsis": [  
{  
"imsi113": "10"  
}  
],  
"update\_time": "2017-10-12 19:49:04"  
}  
}  
]  
}  
}

ES mapping:

PUT face\_imsi  
{  
"mappings": {  
"face\_imsi": {  
"properties": {  
"pid": {  
"type": "keyword"  
},  
"img\_url": {  
"type": "keyword"  
},  
"img\_id": {  
"type": "keyword"  
},  
"update\_time": {  
"type" : "date",  
"doc\_values" : true,  
"format" : "yyyy-MM-dd HH:mm:ss"  
},  
"imsis": {  
"type": "nested",  
"properties": {  
"imsi": { "type": "keyword" },  
"match\_times": { "type": "integer" }  
}  
}  
}  
}  
}  
}

Code:

SparkConf conf = new SparkConf();  
conf.set("es.nodes", "192.168.1.228");  
conf.set("es.port", "9200");  
if (Shell.WINDOWS) {  
conf.setMaster("local");  
conf.setAppName(FaceAndImsiTest.class.getName());  
}  
SparkSession spark = SparkSession.builder().appName("Java Spark SQL basic example").config(conf).config("es.write.operation", "upsert").getOrCreate();  
JavaSparkContext sc = new JavaSparkContext(spark.sparkContext());  
List\<Map\<String, Object\>\> imsis = new LinkedList\<\>();  
Map\<String, Object\> imsi = new HashMap\<\>();  
imsi.put("imsi113","10");  
imsis.add(imsi);

```
List<MatchImsiPo> lm = new LinkedList<>();
MatchImsiPo mp = new MatchImsiPo("123","11","11","2017-10-12 19:49:04",imsis);
lm.add(mp);
JavaRDD<MatchImsiPo> esRdd = sc.parallelize(lm);

Map<String, String> vmId = new HashMap<>();
vmId.put("es.mapping.id", "pid");
JavaEsSpark.saveToEs(esRdd, "face_imsi_test/face_imsi_test",vmId);

```

Version Info

OS: : centos 6.5  
JVM :  
Hadoop/Spark: 2.6.0/2.1.0  
ES-Hadoop :  
ES : 5.5.0  
elasticsearch-spark-20\_2.11 : 5.5.0

---

<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:** [December 1, 2017, 8:09am UTC](https://discuss.elastic.co/t/how-to-update-about-javaesspark-savetoes/106279/2 "2017-12-01T08:09:42Z")

</div>

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