# How to push json data from spark to elastic search

**URL:** <https://discuss.elastic.co/t/how-to-push-json-data-from-spark-to-elastic-search/106288>\
**Category:** Elasticsearch\
**Created:** [November 3, 2017, 8:52am UTC](https://discuss.elastic.co/t/how-to-push-json-data-from-spark-to-elastic-search/106288 "2017-11-03T08:52:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BleedCode](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BleedCode](https://discuss.elastic.co/u/BleedCode)\
**Post date:** [November 3, 2017, 8:52am UTC](https://discuss.elastic.co/t/how-to-push-json-data-from-spark-to-elastic-search/106288/1 "2017-11-03T08:52:48Z")

</div>

```
Hi m new elasticsearch and m trying to push json data to elastic search, But when i execute following code:
JavaDStream<Map<String, Object>> facts =lines.map(json->{
		
	    HashMap<String, Object> factMap = new HashMap<>();
	    Gson gson = new Gson();
	    factMap = (HashMap<String, Object>) gson.fromJson(json, factMap.getClass());
	    factMap.put("timestamp", EpochTime.getTimeStamp());
	    return factMap;
	  
	});
	
	//pushing to ES
	facts.foreachRDD(rdd->{
		JavaEsSpark.saveToEs(rdd, "sample/newdata");
	});

```

I am only getting key part in elasticsearch and not value can. why ? what updates are required in code

---

<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:53am UTC](https://discuss.elastic.co/t/how-to-push-json-data-from-spark-to-elastic-search/106288/2 "2017-12-01T08:53:07Z")

</div>

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