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

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


    Assert.assertNull(solrQuery.getFilterQueries());
  }

  @Test
  public void testWithSimpleStringCriteria() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
    assertProjectionNotPresent(solrQuery);
    assertGroupingNotPresent(solrQuery);
    assertFactingNotPresent(solrQuery);

    Assert.assertEquals(criteria.getQueryString(), solrQuery.getQuery());
  }
View Full Code Here


    Assert.assertEquals(criteria.getQueryString(), solrQuery.getQuery());
  }

  @Test
  public void testWithNullSort() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(null); // do this explicitly

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNull(solrQuery.getSortField());
View Full Code Here

    Assert.assertTrue(solrQuery.getSorts().isEmpty());
  }

  @Test
  public void testWithSortAscOnSingleField() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort("field_2"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_2 asc", solrQuery.getSortField());
    Assert.assertEquals(1, solrQuery.getSorts().size());
View Full Code Here

    Assert.assertEquals(1, solrQuery.getSorts().size());
  }

  @Test
  public void testWithSortDescOnSingleField() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort(Sort.Direction.DESC, "field_2"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_2 desc", solrQuery.getSortField());
    Assert.assertEquals(1, solrQuery.getSorts().size());
View Full Code Here

    Assert.assertEquals(1, solrQuery.getSorts().size());
  }

  @Test
  public void testWithSortAscMultipleFields() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort("field_2", "field_3"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_2 asc,field_3 asc", solrQuery.getSortField());
    Assert.assertEquals(2, solrQuery.getSorts().size());
View Full Code Here

    Assert.assertEquals(2, solrQuery.getSorts().size());
  }

  @Test
  public void testWithSortDescMultipleFields() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort(Sort.Direction.DESC, "field_2", "field_3"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_2 desc,field_3 desc", solrQuery.getSortField());
    Assert.assertEquals(2, solrQuery.getSorts().size());
View Full Code Here

    Assert.assertEquals(2, solrQuery.getSorts().size());
  }

  @Test
  public void testWithSortMixedDirections() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort("field_1"));
    query.addSort(new Sort(Sort.Direction.DESC, "field_2", "field_3"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_1 asc,field_2 desc,field_3 desc", solrQuery.getSortField());
View Full Code Here

    Assert.assertEquals(3, solrQuery.getSorts().size());
  }

  @Test
  public void testWithORDefaultOperator() {
    SimpleQuery query = new SimpleQuery(new SimpleStringCriteria("field_1:value_1"));
    query.setDefaultOperator(Operator.OR);
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("OR", solrQuery.get("q.op"));
  }
View Full Code Here

    Assert.assertEquals("OR", solrQuery.get("q.op"));
  }

  @Test
  public void testWithANDDefaultOperator() {
    SimpleQuery query = new SimpleQuery(new SimpleStringCriteria("field_1:value_1"));
    query.setDefaultOperator(Operator.AND);
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("AND", solrQuery.get("q.op"));
  }
View Full Code Here

    Assert.assertEquals("AND", solrQuery.get("q.op"));
  }

  @Test
  public void testWithNONEDefaultOperator() {
    SimpleQuery query = new SimpleQuery(new SimpleStringCriteria("field_1:value_1"));
    query.setDefaultOperator(Operator.NONE);
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNull(solrQuery.get("q.op"));
  }
View Full Code Here

TOP

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

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.