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

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


    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


    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

    assertFactingNotPresent(solrQuery);
  }

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

    assertFactingNotPresent(solrQuery);
  }

  @Test
  public void testConstructSolrQueryWithSingleFacetOnField() {
    Query query = new SimpleFacetQuery(new Criteria("field_1").is("value_1")).setFacetOptions(new FacetOptions(
        "facet_1"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
View Full Code Here

    assertFactingPresent(solrQuery, "facet_1");
  }

  @Test
  public void testConstructSolrQueryWithSinglePivot() {
    Query query = new SimpleFacetQuery(new Criteria("field_1").is("value_1")).setFacetOptions(new FacetOptions()
        .addFacetOnPivot("field_1", "field_2"));
    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

TOP

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

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.