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

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


        queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testWithinWithDistanceUnitKilometers() {
    Criteria criteria = new Criteria("field_1").within(new Point(48.303056, 14.290556), new Distance(1,
        Metrics.KILOMETERS));
    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=field_1 d=1.0}",
        queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here


  /**
   * @see DATASOLR-142
   */
  @Test(expected = IllegalArgumentException.class)
  public void testCircleForWithinMustNotBeNull() {
    new Criteria("field_1").within((Circle) null);
  }
View Full Code Here

  /**
   * @see DATASOLR-142
   */
  @Test
  public void testWithinCircleWorksCorrectly() {
    Criteria criteria = new Criteria("field_1").within(new Circle(new Point(48.303056, 14.290556), new Distance(1,
        Metrics.KILOMETERS)));
    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=field_1 d=1.0}",
        queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

        queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testWithinWithNullDistance() {
    Criteria criteria = new Criteria("field_1").within(new Point(48.303056, 14.290556), null);
    Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=field_1 d=0.0}",
        queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

        queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testStringCriteria() {
    Criteria criteria = new SimpleStringCriteria("field_1:value_1 AND field_2:value_2");
    Assert.assertEquals("field_1:value_1 AND field_2:value_2", queryParser.createQueryStringFromCriteria(criteria));
  }
View Full Code Here

    Assert.assertEquals("field_1:value_1 AND field_2:value_2", queryParser.createQueryStringFromCriteria(criteria));
  }

  @Test
  public void testStringCriteriaWithMoreFragments() {
    Criteria criteria = new SimpleStringCriteria("field_1:value_1 AND field_2:value_2");
    criteria = criteria.and("field_3").is("value_3");
    Assert.assertEquals("field_1:value_1 AND field_2:value_2 AND field_3:value_3",
        queryParser.createQueryStringFromNode(criteria));
  }
View Full Code Here

        queryParser.createQueryStringFromNode(criteria));
  }

  @Test
  public void testRegisterAlternateConverter() {
    Criteria criteria = new Criteria("field_1").is(100);
    queryParser.registerConverter(new Converter<Number, String>() {

      @Override
      public String convert(Number arg0) {
        return StringUtils.reverse(arg0.toString());
View Full Code Here

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

  @Test
  public void testConstructSimpleSolrQuery() {
    Query query = new SimpleQuery(new Criteria("field_1").is("value_1"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
    assertProjectionNotPresent(solrQuery);
View Full Code Here

  @Test
  public void testConstructSolrQueryWithPagination() {
    int page = 1;
    int pageSize = 100;
    Query query = new SimpleQuery(new Criteria("field_1").is("value_1"))
        .setPageRequest(new PageRequest(page, pageSize));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationPresent(solrQuery, page * pageSize, pageSize);
View Full Code Here

    assertFactingNotPresent(solrQuery);
  }

  @Test
  public void testConstructSimpleSolrQueryWithProjection() {
    Query query = new SimpleQuery(new Criteria("field_1").is("value_1")).addProjectionOnField("projection_1")
        .addProjectionOnField(new SimpleField("projection_2"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
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.