I have some code that works as follows:
- Query for a document using a non-analyzed field (so I should only
get a result on an exact match)
- If the query returned something, I update a counter in the document
and re-index it (using prepareIndex with the id value from the hit)
- If the query did not return anything, then I create a new document
(using prepareIndex without an id)
My expectation is that this code should not produce any documents that
are duplicates (that have the same value in the non-analyzed field
used in the original search).
However, that's not the case. I often find several different versions
of each document.
How is this possible and what can I do to prevent it?