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

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


    return getSolrOperations().queryForPage(query, Product.class);
  }

  @Override
  public FacetPage<Product> findByNameStartingWithAndFacetOnAvailable(String namePrefix) {
    FacetQuery query = new SimpleFacetQuery(new Criteria(SolrSearchableFields.NAME).startsWith(namePrefix));
    query.setFacetOptions(new FacetOptions(SolrSearchableFields.AVAILABLE));
    return getSolrOperations().queryForFacetPage(query, Product.class);
  }
View Full Code Here


    if (solrQueryMethod.isPageQuery() || solrQueryMethod.isSliceQuery()) {
      if (solrQueryMethod.isFacetQuery() && solrQueryMethod.isHighlightQuery()) {
        throw new InvalidDataAccessApiUsageException("Facet and Highlight cannot be combined.");
      }
      if (solrQueryMethod.isFacetQuery()) {
        FacetQuery facetQuery = SimpleFacetQuery.fromQuery(query, new SimpleFacetQuery());
        facetQuery.setFacetOptions(extractFacetOptions(solrQueryMethod, accessor));
        return new FacetPageExecution(accessor.getPageable()).execute(facetQuery);
      }
      if (solrQueryMethod.isHighlightQuery()) {
        HighlightQuery highlightQuery = SimpleHighlightQuery.fromQuery(query, new SimpleHighlightQuery());
View Full Code Here

    solrTemplate.saveBean(new ExampleSolrBean("id_4", "name2", "category2", 1, false));
    solrTemplate.saveBean(new ExampleSolrBean("id_5", "name2", "category2", 2, false));
    solrTemplate.saveBean(new ExampleSolrBean("id_6", "name2", "category1", 1, true));
    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

      values.add(createExampleBeanWithId(Integer.toString(i)));
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
        .setFacetOptions(new FacetOptions().addFacetOnField("name").addFacetOnField("id").setFacetLimit(5));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);

    for (Page<FacetFieldEntry> facetResultPage : page.getFacetResultPages()) {
View Full Code Here

      values.add(createExampleBeanWithId(Integer.toString(i)));
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
        .setFacetOptions(new FacetOptions().addFacetOnPivot("cat", "name"));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);

    List<FacetPivotFieldEntry> pivotEntries = page.getPivot("cat,name");
View Full Code Here

      values.add(bean);
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new SimpleStringCriteria("*:*"));
    q.setFacetOptions(new FacetOptions(new SimpleQuery(new SimpleStringCriteria("inStock:true")), new SimpleQuery(
        new SimpleStringCriteria("inStock:false"))));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);

    Page<FacetQueryEntry> facetQueryResultPage = page.getFacetQueryResult();
View Full Code Here

    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("name").setFacetLimit(5).setFacetPrefix("spr"));

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

    ExampleSolrBean island = new ExampleSolrBean("3", "java", "island");
    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"));
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

TOP

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

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.