Elasticsearch Java API Client BulkRequest

Hello , I am using new JAVA API Client version 8.7
in my Java multiThreaded Application
I am doing two task
1)task1) Reading , first different threads reading data from elasticsearch indexes
2)task2)After reading data and doing some business logic different threads are indexing into different elasticsearch indexes
now for a specific data , one thread is indexing record , and othere thread is doing some partial update on that record.
When Application is live , then i am not getting any data inconsistency , but when application is off , and there are data in read part , when my application is starting , the record which is first indexed and then updated is getting deleted.
i dont know why , i am not using any delete query.

instead of getting updated that document is getting deleted , i have tried in my code when i am not updating that document , then that document is presnet ?
why i am getting these incocnsistency . in my logs i have seen that data is getting updated.
in short i elasticserach this record is not present why?"_id":"2251799813686674"
BulkItemResponse is BulkResponse: {"errors":false,"items":[{"update":{"_id":"2251799813686674","_index":"logistics-orders-view","status":201,"_primary_term":1,"result":"created","_seq_no":54,"_shards":{"failed":0.0,"successful":1.0,"total":2.0},"_version":1}}BulkItemResponse is BulkResponse: {"errors":false,"items":[{"update":{"_id":"2251799813686674","_index":"logistics-orders-view","status":200,"_primary_term":1,"result":"updated","_seq_no":56,"_shards":{"failed":0.0,"successful":1.0,"total":2.0},"_version":2}}


Hard to tell but Elasticsearch does not remove documents unless it was told so.
When you stop your application, can you then go to the Kibana dev console and check if documents are missing or not?

If so, we can suspect the code which is called when stopping the application.
If not, we can suspect the code which is called when starting the application again.

I'd guess that you are deleting the existing index at startup or that you are using a Docker container without persisting the volumes...

May be share your code?

Yes i have verified with kibana console , the document is missing.
And index is not deleting at startup neither i am using docker container without persisitng the volumes.
Here is code
For indexing part
bulkOperationBuilder.update(u -> u.index(this.logisticsViewTemplate.getName()).id(entity.getId())
.action(a -> a.upsert(entity).doc(updateFields)).retryOnConflict(3)).build();

This part i am using for updating part
Map<String , Object> updateFields = new HashMap<>();
updateFields.put(FIELD_NAME_INCIDENT , true);

Please read this about how to format.

There's nothing I can tell from that code.

May be share a full example of code which is doing the same thing and reproduce your issue.

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