I have a Spring data solr project, and my repository class is a simple SolrCrudRepository. My question is how to make Spring data solr use atomic update feature of Solr 4. In other words, in order for atomic updates to work, what extra configuration do I need to make, so that Repository.save() works.
Asked
Active
Viewed 1,221 times
1
-
And Note that I have defined a SolrServer bean as well as SolrOperations, – Sathyakumar Seshachalam Mar 14 '16 at 16:14
2 Answers
1
Use PartialUpdate
along with SolrTemplate
.
PartialUpdate update = new PartialUpdate("id", "123456789");
update.setValueOfField("name", "updated-name");
solrTemplate.saveBean(update);
solrTemplate.commit();
Please have a look at ITestSolrTemplate.

Christoph Strobl
- 6,491
- 25
- 33
-
Thanks. I was using Spring boot and data solr starter and also using SolrJ to save the bean, So after many hours of debugging, I found that steps in this project structure will be to first disable SolrRepositoriesConfiguration and make multi core support as false (its made true by SolrRepositoriesAutoConfiguration and SolrTemplate bean I define never gets used). I also had to define SolrTemplate bean with converter set as SolrJConverter. Only then atomic updates work. I am marking the above as Correct Answer because if atomic updates have to work you have to implement Update – Sathyakumar Seshachalam Mar 16 '16 at 05:52
0
SolrInputDocument doc = new SolrInputDocument();
Map<String, String> partialUpdate = new HashMap<>();
partialUpdate.put("set", "value to update");
doc.addField("id", "100");
doc.addField("field name ", partialUpdate);
UpdateRequest up = new UpdateRequest();
up.setBasicAuthCredentials("username", "@password");
up.add(doc);
up.process(solrClient, "corename");
up.commit(solrClient, "corename");