List of usage examples for org.springframework.data.solr.core.query PartialUpdate add
public void add(String fieldName, Object value)
From source file:com.nixmash.springdata.solr.repository.custom.CustomProductRepositoryImpl.java
@Override public void updateProductName(Product product) { logger.debug("Performing partial update for todo entry: {}", product); PartialUpdate update = new PartialUpdate(Product.ID_FIELD, product.getId().toString()); update.add(Product.NAME_FIELD, product.getName()); solrTemplate.saveBean(update);/*from ww w . java 2 s.c o m*/ solrTemplate.commit(); }
From source file:org.springframework.data.solr.core.SolrTemplateTests.java
@SuppressWarnings("unchecked") @Test//w ww .jav a 2 s . c o m public void testPartialUpdate() throws SolrServerException, IOException { Mockito.when(solrServerMock.add(Mockito.any(SolrInputDocument.class))).thenReturn(new UpdateResponse()); PartialUpdate update = new PartialUpdate("id", "update-id"); update.add("field_1", "update"); solrTemplate.saveBean(update); ArgumentCaptor<SolrInputDocument> captor = ArgumentCaptor.forClass(SolrInputDocument.class); Mockito.verify(solrServerMock, Mockito.times(1)).add(captor.capture()); Assert.assertTrue(captor.getValue().getFieldValue("field_1") instanceof Map); Assert.assertEquals("update", ((Map<String, Object>) captor.getValue().getFieldValue("field_1")).get("set")); }