thanks its working fine for me i used below code
Email email=new Email();
email.setCounter("0");
email.setCreatets(java.time.LocalDate.now()+"");
email.setEmail("srinivas.thouti@gmail.com");
email.setLast_updated_ts(java.time.LocalDate.now()+"");
email.setSource("Customer Centricity");
email.setUrl(summary);
final ObjectMapper mapper = new ObjectMapper();
RestHighLevelClient esClient=new RestHighLevelClient(RestClient.builder(HttpHost.create("http://apsrp06825:9209")));
byte[] bytes = mapper.writeValueAsBytes(email);
esClient.index(new IndexRequest("email_subscription", "data", email.idAsString()).source(bytes, XContentType.JSON));
but my question is i need to return some automated genarated value of id how can i do this
i mean while inserting record into elastic i am generating id value, now i need to get that incremented value as return while inserting.
one more query sir how can i get particular record from index.
for example i have id like this 8gH1xWQBtT8Pa64GFEMX i need to get all details using java.
There is nothing like an automatic sequence you can use in elasticsearch. But elasticsearch can always generate unique ids for you if you don't specify the Id.
hi sir i am unable to find out exact example and i am prepared like this
Email email=new Email();
email.setCounter(Integer.parseInt(subData.getString("counter"))+1+"");
email.setCreatets(subData.getString("createts"));
email.setEmail(subData.getString("email"));
email.setSource(subData.getString("source"));
email.setLast_updated_ts(java.time.LocalDate.now()+" "+java.time.LocalTime.now());
email.setUrl(subData.getString("url"));
String jsonStr = mapper.writeValueAsString(email);
UpdateRequest updateRequest = new UpdateRequest();
updateRequest.index("email_subscription");
updateRequest.type("data");
updateRequest.id("21.33.81.65.32.45");
updateRequest.doc(jsonBuilder().startObject()
.field("gender", "male")
.endObject());
esClient.update(updateRequest).getId();
but i am getting some issue in the code of jsonBuilder().startObject()
Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.
Or use markdown style like:
```
CODE
```
This is the icon to use if you are not using markdown format:
There's a live preview panel for exactly this reasons.
Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.
Please share what is the exact problem you have.
Also, I don't recommend using the update API unless you absolutely need it but prefer the index document API.
i am unable to find out exact example for update particular record by using id in elastic search and i am prepared like this to update record in elastic index
Please share what is the exact problem you have.
Also, I don't recommend using the update API unless you absolutely need it but prefer the index document API.
will you provide example for update the particular document in elastic using java.i used Index Document Api. below is my prepared query for update when i run this code record not updated in elastic
is it possible delete and insert the record into elastic at a time .
my scenario is i have record with id ' 1' delete that record and insert with some updated values with same id.
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.