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

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


  }

  @Test
  public void testConstructSolrQueryWithSingleFacetFilterQuery() {
    FacetQuery query = new SimpleFacetQuery(new Criteria("field_1").is("value_1")).setFacetOptions(new FacetOptions()
        .addFacetQuery(new SimpleQuery(new SimpleStringCriteria("field_2:[* TO 5]"))));

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
View Full Code Here


  }

  @Test
  public void testConstructSolrQueryWithMultipleFacetFilterQuerues() {
    FacetQuery query = new SimpleFacetQuery(new Criteria("field_1").is("value_1")).setFacetOptions(new FacetOptions()
        .addFacetQuery(new SimpleQuery(new SimpleStringCriteria("field_2:[* TO 5]"))).addFacetQuery(
            new SimpleQuery(new Criteria("field_3").startsWith("prefix"))));

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
View Full Code Here

    Assert.assertArrayEquals(new String[] { "field_2:[* TO 5]", "field_3:prefix*" }, solrQuery.getFacetQuery());
  }

  @Test
  public void testWithFilterQuery() {
    Query query = new SimpleQuery(new Criteria("field_1").is("value_1")).addFilterQuery(new SimpleFilterQuery(
        new Criteria("filter_field").is("filter_value")));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);

    String[] filterQueries = solrQuery.getFilterQueries();
    Assert.assertEquals(1, filterQueries.length);
View Full Code Here

    Assert.assertEquals("filter_field:filter_value", filterQueries[0]);
  }

  @Test
  public void testWithEmptyFilterQuery() {
    Query query = new SimpleQuery(new Criteria("field_1").is("value_1")).addFilterQuery(new SimpleQuery());
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);

    Assert.assertNull(solrQuery.getFilterQueries());
  }
View Full Code Here

  }

  @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);
View Full Code Here

  }

  @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());
    Assert.assertTrue(solrQuery.getSorts().isEmpty());
  }
View Full Code Here

  }

  @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

  }

  @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

  }

  @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

  }

  @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

TOP

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

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.