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

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


    BeanWithEnum loaded = saveAndLoad(bean);

    Assert.assertEquals(bean.id, loaded.id);
    Assert.assertEquals(bean.enumProperty, loaded.enumProperty);

    Query query = new SimpleQuery(new Criteria("enumProperty_s").is(LiteralNumberEnum.TWO));

    BeanWithEnum loadedViaProperty = solrTemplate.queryForObject(query, BeanWithEnum.class);
    Assert.assertEquals(bean.id, loadedViaProperty.id);
    Assert.assertEquals(bean.enumProperty, loadedViaProperty.enumProperty);
  }
View Full Code Here


    this.queryParser = new DefaultQueryParser();
  }

  @Test
  public void testIs() {
    Criteria criteria = new Criteria("field_1").is("is");
    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:is", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:is", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testMultipleIs() {
    Criteria criteria = new Criteria("field_1").is("is").is("another is");
    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:(is \"another is\")", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:(is \"another is\")", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testEndsWith() {
    Criteria criteria = new Criteria("field_1").endsWith("end");

    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:*end", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:*end", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testEndsWithMulitpleValues() {
    Criteria criteria = new Criteria("field_1").endsWith(Arrays.asList("one", "two", "three"));

    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:(*one *two *three)", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:(*one *two *three)", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testStartsWith() {
    Criteria criteria = new Criteria("field_1").startsWith("start");

    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:start*", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:start*", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testStartsWithMultipleValues() {
    Criteria criteria = new Criteria("field_1").startsWith(Arrays.asList("one", "two", "three"));

    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:(one* two* three*)", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:(one* two* three*)", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testContains() {
    Criteria criteria = new Criteria("field_1").contains("contains");

    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:*contains*", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:*contains*", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testContainsWithMultipleValues() {
    Criteria criteria = new Criteria("field_1").contains(Arrays.asList("one", "two", "three"));

    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:(*one* *two* *three*)", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:(*one* *two* *three*)", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testExpression() {
    Criteria criteria = new Criteria("field_1").expression("(have fun using +solr && expressions*)");
    Assert.assertEquals("field_1:(have fun using +solr && expressions*)",
        queryParser.createQueryStringFromCriteria(criteria));
  }
 
View Full Code Here

TOP

Related Classes of org.springframework.data.solr.core.query.Criteria

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.