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

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


        queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testCriteriaChain() {
    Criteria criteria = new Criteria("field_1").startsWith("start").endsWith("end").contains("contains").is("is");
    Assert.assertEquals("field_1", criteria.getField().getName());
    Assert.assertEquals("field_1:(start* *end *contains* is)", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here


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

  @Test
  public void testAnd() {
    Criteria criteria = new Criteria("field_1").startsWith("start").endsWith("end").and("field_2").startsWith("2start")
        .endsWith("2end");
    Assert.assertEquals("field_1:(start* *end) AND field_2:(2start* *2end)",
        queryParser.createQueryStringFromNode(criteria));
  }
 
View Full Code Here

        queryParser.createQueryStringFromNode(criteria));
  }

  @Test
  public void testOr() {
    Criteria criteria = new Criteria("field_1").startsWith("start").or("field_2").endsWith("end").startsWith("start2");
    Assert.assertEquals("field_1:start* OR field_2:(*end start2*)", queryParser.createQueryStringFromNode(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:start* OR field_2:(*end start2*)", queryParser.createQueryStringFromNode(criteria));
  }

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

    Assert.assertEquals("field_1:\"white space\"", queryParser.createQueryStringFromCriteria(criteria));
  }

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

    Assert.assertEquals("field_1:\"with \\\"quote\"", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testIsNot() {
    Criteria criteria = new Criteria("field_1").is("value_1").not();
    Assert.assertEquals("-field_1:value_1", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

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

  @Test
  public void testFuzzy() {
    Criteria criteria = new Criteria("field_1").fuzzy("value_1");
    Assert.assertEquals("field_1:value_1~", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

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

  @Test
  public void testFuzzyWithDistance() {
    Criteria criteria = new Criteria("field_1").fuzzy("value_1", 0.5f);
    Assert.assertEquals("field_1:value_1~0.5", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:value_1~0.5", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testSloppy() {
    Criteria criteria = new Criteria("field_1").sloppy("value1 value2", 2);
    Assert.assertEquals("field_1:\"value1 value2\"~2", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:\"value1 value2\"~2", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testBoost() {
    Criteria criteria = new Criteria("field_1").is("value_1").boost(2f);
    Assert.assertEquals("field_1:value_1^2.0", 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.