Package org.springframework.data.solr.core.query

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


    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    List<Update> updates = new ArrayList<Update>(5);
    for (int i = 0; i < 5; i++) {
      PartialUpdate update = new PartialUpdate("id", Integer.toString(i));
      update.add("popularity", 5);
      updates.add(update);
    }
    solrTemplate.saveBeans(updates);
    solrTemplate.commit();
View Full Code Here


    ExampleSolrBean loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);

    Assert.assertEquals(1, loaded.getCategory().size());

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setValueOfField("popularity", 500);
    update.setValueOfField("cat", Arrays.asList("cat-1", "cat-2", "cat-3"));
    update.setValueOfField("name", null);

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

    loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);
View Full Code Here

    ExampleSolrBean loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);

    Assert.assertEquals(1, loaded.getCategory().size());

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setValueOfField("popularity", 500);
    update.setValueOfField("name", null);
    update.setValueOfField("cat", Arrays.asList("cat-1", "cat-2", "cat-3"));

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

    loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);
View Full Code Here

    ExampleSolrBean toInsert = createDefaultExampleBean();

    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setVersion(1L);
    update.setValueOfField("popularity", 500);

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

    ExampleSolrBean loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);
View Full Code Here

    ExampleSolrBean toInsert = createDefaultExampleBean();

    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setVersion(2L);
    update.setValueOfField("popularity", 500);

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

  private UpdateToSolrInputDocumentConverter converter = new UpdateToSolrInputDocumentConverter();

  @Test
  public void testConvertWithIdAndVersion() {
    PartialUpdate update = new PartialUpdate("id", "1");
    update.setVersion(1);

    SolrInputDocument document = converter.convert(update);

    Assert.assertEquals(update.getIdField().getValue(), document.getFieldValue(update.getIdField().getName()));
    Assert.assertEquals(update.getVersion(), document.getFieldValue("_version_"));
  }
View Full Code Here

    Assert.assertEquals(update.getVersion(), document.getFieldValue("_version_"));
  }

  @Test
  public void testConvertWithIdNoVersion() {
    PartialUpdate update = new PartialUpdate("id", "1");

    SolrInputDocument document = converter.convert(update);

    Assert.assertEquals(update.getIdField().getValue(), document.getFieldValue(update.getIdField().getName()));
    Assert.assertNull(document.getFieldValue("_version_"));
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Test
  public void testConvertWhenSettingValue() {
    PartialUpdate update = new PartialUpdate("id", "1");
    update.setValueOfField("field_1", "valueToSet");

    SolrInputDocument document = converter.convert(update);

    Assert.assertTrue(document.getFieldValue("field_1") instanceof Map);
    Assert.assertEquals("valueToSet", ((Map<String, Object>) document.getFieldValue("field_1")).get("set"));
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Test
  public void testConvertWhenAddingValue() {
    PartialUpdate update = new PartialUpdate("id", "1");
    update.addValueToField("field_1", "valueToAdd");

    SolrInputDocument document = converter.convert(update);

    Assert.assertTrue(document.getFieldValue("field_1") instanceof Map);
    Assert.assertEquals("valueToAdd", ((Map<String, Object>) document.getFieldValue("field_1")).get("add"));
View Full Code Here

  }

  @Test
  @SuppressWarnings("unchecked")
  public void testConvertWhenIncreasingValue() {
    PartialUpdate update = new PartialUpdate("id", "1");
    update.increaseValueOfField("field_1", 1);

    SolrInputDocument document = converter.convert(update);

    Assert.assertTrue(document.getFieldValue("field_1") instanceof Map);
    Assert.assertEquals(1, ((Map<String, Object>) document.getFieldValue("field_1")).get("inc"));
View Full Code Here

TOP

Related Classes of org.springframework.data.solr.core.query.PartialUpdate$IdField

Copyright © 2018 www.massapicom. 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.