spring-data-solr

Atomic update not working Spring data solr


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.


Solution

  • 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.