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

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


    ExampleSolrBean language = new ExampleSolrBean("4", "java", "language");

    solrTemplate.saveBeans(Arrays.asList(season, framework, island, language));
    solrTemplate.commit();
    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
        .setFacetOptions(new FacetOptions().addFacetOnField(new FieldWithFacetParameters("name").setPrefix("spr"))
            .addFacetOnField("cat").setFacetPrefix("lan").setFacetLimit(5));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);
    Page<FacetFieldEntry> facetPage = page.getFacetResultPage(new SimpleField("name"));
    for (FacetFieldEntry entry : facetPage) {
View Full Code Here


    solrTemplate.commit();

    SimpleFacetQuery groupQuery = new SimpleFacetQuery(new SimpleStringCriteria("*:*"));
    GroupOptions groupOptions = new GroupOptions();
    groupQuery.setGroupOptions(groupOptions);
    groupQuery.setFacetOptions(new FacetOptions("inStock"));
    groupOptions.addGroupByField("name");
    groupOptions.setGroupFacets(true);
    FacetPage<ExampleSolrBean> groupResultPage = solrTemplate.queryForFacetPage(groupQuery, ExampleSolrBean.class);

    Page<FacetFieldEntry> facetResultPage = groupResultPage.getFacetResultPage("inStock");
View Full Code Here

    return nl;
  }

  private FacetQuery createFacetQuery(SolrDataQuery... facetQueries) {
    FacetQuery fq = new SimpleFacetQuery(new SimpleStringCriteria("*:*"));
    fq.setFacetOptions(new FacetOptions(facetQueries));
    return fq;
  }
View Full Code Here

    return fq;
  }

  private FacetQuery createFacetQuery(String... facetFields) {
    FacetQuery fq = new SimpleFacetQuery(new Criteria(facetFields[0]));
    fq.setFacetOptions(new FacetOptions(facetFields));
    return fq;
  }
View Full Code Here

    return fq;
  }

  private FacetQuery createFacetPivotQuery(String... pivotFieldNames) {
    FacetQuery fq = new SimpleFacetQuery(new Criteria("field_1"));
    fq.setFacetOptions(new FacetOptions().addFacetOnPivot(pivotFieldNames));
    return fq;
  }
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

    assertPivotFactingPresent(solrQuery, "field_1,field_2");
  }

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

    assertFactingPresent(solrQuery, "facet_1", "facet_2");
  }

  @Test
  public void testConstructSolrQueryWithMultiplePivot() {
    FacetQuery query = new SimpleFacetQuery(new Criteria("field_1").is("value_1")).setFacetOptions(new FacetOptions()
        .addFacetOnPivot("field_1", "field_2").addFacetOnPivot("field_2", "field_3"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
View Full Code Here

  }

  @Test
  public void testConstructSolrQueryWithFacetPrefix() {
    FacetQuery query = new SimpleFacetQuery(new Criteria("field_1").is("value_1"));
    FacetOptions facetOptions = new FacetOptions(new SimpleField("facet_1"), new SimpleField("facet_2"));
    facetOptions.setFacetPrefix("prefix");
    query.setFacetOptions(facetOptions);

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNotNull(solrQuery);
    assertQueryStringPresent(solrQuery);
    assertPaginationNotPresent(solrQuery);
    assertProjectionNotPresent(solrQuery);
    assertGroupingNotPresent(solrQuery);
    assertFactingPresent(solrQuery, "facet_1", "facet_2");
    Assert.assertEquals(facetOptions.getFacetPrefix(), solrQuery.getParams("facet.prefix")[0]);
  }
View Full Code Here

TOP

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

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.