Package org.elasticsearch.search.facet.terms

Examples of org.elasticsearch.search.facet.terms.TermsFacetBuilder


            srb = standardSearchRequest(query, IndexHelper.determineAffectedIndices(indexRangeService, deflector, range));
        } else {
            srb = filteredSearchRequest(query, filter, IndexHelper.determineAffectedIndices(indexRangeService, deflector, range));
        }

        TermsFacetBuilder terms = new TermsFacetBuilder(TERMS_FACET_NAME);
        terms.global(false);
        terms.field(field);
        terms.size(size);

        terms.facetFilter(standardFilters(range, filter));

        srb.addFacet(terms);

        final SearchRequest request = srb.request();
        SearchResponse r = c.search(request).actionGet();
View Full Code Here


      List<String> facetQueries = params.get("facet.query");

      if (facetFields != null && !facetFields.isEmpty()) {
        for (String facetField : facetFields) {
          TermsFacetBuilder termsFacetBuilder = new TermsFacetBuilder(facetField);
          termsFacetBuilder.size(facetLimit);
          termsFacetBuilder.field(facetField);

          if (facetSort != null && facetSort.equals("index")) {
            termsFacetBuilder.order(TermsFacet.ComparatorType.TERM);
          } else {
            termsFacetBuilder.order(TermsFacet.ComparatorType.COUNT);
          }

          searchSourceBuilder.facet(termsFacetBuilder);
        }
      }
View Full Code Here

    public static FilterFacetBuilder filterFacet(String facetName, FilterBuilder filter) {
        return new FilterFacetBuilder(facetName).filter(filter);
    }

    public static TermsFacetBuilder termsFacet(String facetName) {
        return new TermsFacetBuilder(facetName);
    }
View Full Code Here

            }

            SearchRequestBuilder srb = createSearchBuilder();
            lastQ.initRequestBuilder(srb);

            TermsFacetBuilder tfb = FacetBuilders.termsFacet(TAG).field(TAG);
            if (!secPart.trim().isEmpty())
                tfb.regex(secPart + ".*", Pattern.DOTALL);

            srb.addFacet(tfb);
            SearchResponse rsp = query(new ArrayList<JUser>(), srb.execute().actionGet());
            Set<String> res = new TreeSet<String>();
            TermsFacet tf = rsp.facets().facet(TAG);
View Full Code Here

        splitFilters.put("others", others);
        return splitFilters;
    }

    private void addFacetPathsResult(SearchSourceBuilder searchSourceBuilder) {
        TermsFacetBuilder facetBuilder = new TermsFacetBuilder("facet_paths_result")
                .field("facetPaths")
                .order(TermsFacet.ComparatorType.TERM).size(100000);

        searchSourceBuilder.facet(facetBuilder);
    }
View Full Code Here

    }

    public List<Tag> findTags() {
        List<Tag> tags = Lists.newArrayList();

        TermsFacetBuilder facetBuilder = new TermsFacetBuilder("tags");
        facetBuilder.field("tags").size(20);
        facetBuilder.facetFilter(getNowDateFilter());

        SearchResponse searchResponse = node.client().prepareSearch(INDEX).
            setTypes(TYPE).
            setQuery(QueryBuilders.matchAllQuery()).
            setSize(0).
View Full Code Here

  }

  @Override
  public FacetBuilder getFacet() {
    Assert.notEmpty(fields, "Please select at last one field !!!");
    TermsFacetBuilder builder = FacetBuilders.termsFacet(getName()).fields(fields).size(size);
    switch (order) {

      case descTerm:
        builder.order(TermsFacet.ComparatorType.REVERSE_TERM);
        break;
      case ascTerm:
        builder.order(TermsFacet.ComparatorType.TERM);
        break;
      case ascCount:
        builder.order(TermsFacet.ComparatorType.REVERSE_COUNT);
        break;
      default:
        builder.order(TermsFacet.ComparatorType.COUNT);
    }
    if (ArrayUtils.isNotEmpty(excludeTerms)) {
      builder.exclude(excludeTerms);
    }

    if (allTerms) {
      builder.allTerms(allTerms);
    }

    if (StringUtils.isNotBlank(regex)) {
      builder.regex(regex, regexFlag);
    }

    return builder;
  }
View Full Code Here

      List<String> facetQueries = params.get("facet.query");

      if (facetFields != null && !facetFields.isEmpty()) {
        for (String facetField : facetFields) {
          TermsFacetBuilder termsFacetBuilder = new TermsFacetBuilder(facetField);
          termsFacetBuilder.size(facetLimit);
          termsFacetBuilder.field(facetField);

          if (facetSort != null && facetSort.equals("index")) {
            termsFacetBuilder.order(TermsFacet.ComparatorType.TERM);
          } else {
            termsFacetBuilder.order(TermsFacet.ComparatorType.COUNT);
          }

          searchSourceBuilder.facet(termsFacetBuilder);
        }
      }
View Full Code Here

     * @throws Exception
     * <br>See <a href="http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html">documentation</a>
     */
    @Test
    public void termsFacet() throws Exception {
        TermsFacetBuilder facet = FacetBuilders.termsFacet("f")
                .field("brand")
                .size(10);

        TermsFacet f = (TermsFacet) launchSearch(facet, "f");

View Full Code Here

     * @throws Exception
     * <br>See <a href="http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html">documentation</a>
     */
    @Test
    public void facetFilterOnTermFacet() throws Exception {
        TermsFacetBuilder facet = FacetBuilders.termsFacet("f")
                .field("brand")
                .facetFilter(FilterBuilders.termFilter("colour", "pale"));

        TermsFacet f = (TermsFacet) launchSearch(facet, "f");

View Full Code Here

TOP

Related Classes of org.elasticsearch.search.facet.terms.TermsFacetBuilder

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.