Hello
I would like to add a document to a collection in ElasticSearch using Java. Is there a sample program with explanation available?
Thank You
Hello
I would like to add a document to a collection in ElasticSearch using Java. Is there a sample program with explanation available?
Thank You
I hope this is right:
//Add documents
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("user", "kimchy");
jsonMap.put("postDate", new Date());
jsonMap.put("message", "trying out Elasticsearch");
IndexRequest indexRequest = new IndexRequest("posts", "doc", "1")
.source(jsonMap);
IndexResponse indexResponse = (IndexResponse) client.index(indexRequest);
System.out.println(indexResponse.toString());
Also what about the 'Rest Client' code? Would it be the same?
Thank You
Thé link I pasted is for the rest Client.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.