We want to prevent Solr from overwriting an existing document if document's
ID already exists in the core.

This unit test fails because the update/overwrite is permitted:

public void testUpdateProhibited() {
  final Index index = baseInstance();
  indexRepository.save(index);
  Index index0 = indexRepository.findById(INDEX_ID).get();
  index0.setContents("AAA");
  indexRepository.save(index0);
  Index index1 = indexRepository.findById(INDEX_ID).get();
  assertThat(index, equalTo(index1));
}


The failure is:
Expected: <Index(contents=AAA, id=a2d8464ed41b4766a888617ecbcac573, ...>
but: was <Index(contents=Winterfell, id=a2d8464ed41b4766a888617ecbcac573,
...>

What do I need to do prevent the second save from overwriting the existing
document?

I commented out the updateHandler in the solr config file, to no effect.
We are using Spring Data with Solr 8.1.
In the core's schema, id is defined as unique  like this:
<uniqueKey>id</uniqueKey>

Reply via email to