0

So, recently we changed ID generation from our custom to auto-made by Elastic. Previously it was a content-based function so it was guaranteed to have the same IDs for the same documents, but it was dropped to cope with duplicates. Now we use IDs generated by Elastic itself, so the same documents won't have the same IDs.

What will happen if we upsert an existing document with the same content and the same ID? Will it trigger reindexing? Or it will detect that nothing is changed and will do nothing?

Renat Zamaletdinov
  • 1,210
  • 1
  • 21
  • 36

2 Answers2

1

Yes, there will be no re-indexing. Below is a sample response:

 {
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "result" : "noop", // <============ No Operation
  "_shards" : {
    "total" : 0,
    "successful" : 0,
    "failed" : 0
  },
  "_seq_no" : 3,
  "_primary_term" : 3
}
Sahil Gupta
  • 2,028
  • 15
  • 22
1

I am not sure why you will you want to update a document of same ID with same content. By default ES understand and if there is not change in document then it do not update the document and will respond back as output

"result": "noop"

But if your need is to update the document regardless of, then you can disable this behavior by setting

"detect_noop": false

  • Our custom ID was an optimization not to index the same document twice :) Now it's gone and I'm curious if we lost anything using auto-generated IDs – Renat Zamaletdinov May 21 '21 at 12:00
  • 1
    Hard to say but as per best practices it is recommended to use ES generated ids OR if you have source system from where search streams are coming use the source system ids. – Abhishek Jain May 21 '21 at 12:18