Examples of PartialUpdate


Examples of org.springframework.data.solr.core.query.PartialUpdate

    repo.save(initial);

    Product loaded = repo.findOne(initial.getId());
    Assert.assertEquals(1, loaded.getCategories().size());

    PartialUpdate update = new PartialUpdate(SearchableProduct.ID_FIELD, initial.getId());
    update.setValueOfField(SearchableProduct.POPULARITY_FIELD, 500);
    update.setValueOfField(SearchableProduct.CATEGORY_FIELD, Arrays.asList("cat-1", "cat-2", "cat-3"));
    update.setValueOfField(SearchableProduct.NAME_FIELD, null);
    solrOperations.saveBean(update);
    solrOperations.commit();

    loaded = repo.findOne(initial.getId());
    Assert.assertEquals(Integer.valueOf(500), loaded.getPopularity());
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

        Product.class);
  }

  @Override
  public void updateProductCategory(String productId, List<String> categories) {
    PartialUpdate update = new PartialUpdate(SearchableProduct.ID_FIELD, productId);
    update.setValueOfField(SearchableProduct.CATEGORY_FIELD, categories);

    solrTemplate.saveBean(update);
    solrTemplate.commit();
  }
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

  }

  @SuppressWarnings("unchecked")
  @Test
  public void testWriteUpdate() {
    PartialUpdate update = new PartialUpdate("id", "123");
    update.add("language", "java");
    update.add("since", 1995);

    SolrInputDocument solrDocument = new SolrInputDocument();
    converter.write(update, solrDocument);

    Assert.assertEquals(update.getIdField().getValue(), solrDocument.getFieldValue(update.getIdField().getName()));
    Assert.assertTrue(solrDocument.getFieldValue("since") instanceof Map);
    Assert.assertEquals(1995, ((Map<String, Object>) solrDocument.getFieldValue("since")).get("set"));
  }
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

  @Test
  public void testPartialUpdate() throws SolrServerException, IOException {
    Mockito.when(solrServerMock.add(Mockito.any(SolrInputDocument.class), Mockito.eq(-1))).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(), Mockito.eq(-1));
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setPopularity(10);
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.add("name", "updated-name");
    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

    toInsert.setPopularity(10);
    toInsert.setCategory(Arrays.asList("nosql"));
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.add(new SimpleUpdateField("cat", "spring-data-solr", UpdateAction.ADD));
    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setPopularity(10);
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.add(new SimpleUpdateField("popularity", 1, UpdateAction.INC));
    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setPopularity(10);
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setValueOfField("cat", Arrays.asList("spring", "data", "solr"));
    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

    toInsert.setCategory(Arrays.asList("spring", "data", "solr"));
    toInsert.setPopularity(10);
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setValueOfField("cat", Collections.emptyList());

    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));
View Full Code Here

Examples of org.springframework.data.solr.core.query.PartialUpdate

    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setPopularity(10);
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.addValueToField("cat", Arrays.asList("spring", "data", "solr"));

    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.