Codota Logo
TermFacetResult
Code IndexAdd Codota to your IDE (free)

How to use
TermFacetResult
in
io.sphere.sdk.search

Best Java code snippets using io.sphere.sdk.search.TermFacetResult (Showing top 13 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: commercetools/commercetools-jvm-sdk

  public static TermFacetResult of(final Long missing, final Long total, final Long other, final List<TermStats> terms) {
    return new TermFacetResult(missing, total, other, terms);
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void parsesTermFacetResults() throws Exception {
  final TermFacetResult termFacet = searchResult.getTermFacetResult(TERM_FACET_KEY);
  assertThat(termFacet.getMissing()).isEqualTo(44);
  assertThat(termFacet.getTotal()).isEqualTo(6937);
  assertThat(termFacet.getOther()).isEqualTo(0);
  assertThat(termFacet.getTerms()).hasSize(21);
  assertThat(termFacet.getTerms().get(2)).isEqualTo(TermStats.of("4B432E_1", 585L));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void parsesTermFacetResultsProductCounts() throws Exception {
  final TermFacetResult termFacet = searchResult.getTermFacetResult(TERM_FACET_COUNTING_PRODUCTS_KEY);
  assertThat(termFacet.getTerms()).hasSize(2);
  assertThat(termFacet.getTerms().get(0).getProductCount()).isEqualTo(372);
  assertThat(termFacet.getTerms().get(1).getProductCount()).isEqualTo(195);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void facetAndFilter() {
  final ReviewRatingStatisticsFacetedSearchSearchModel<ProductProjection> reviewRatingsModel
      = ProductProjectionSearchModel.of().facetedSearch().reviewRatingStatistics();
  final TermFacetedSearchExpression<ProductProjection> count = reviewRatingsModel.count().is("20");
  final TermFacetedSearchExpression<ProductProjection> averageRating = reviewRatingsModel.averageRating().is("2.7");
  final TermFacetedSearchExpression<ProductProjection> highestRating = reviewRatingsModel.highestRating().is(String.valueOf(HIGHEST_RATING));
  final TermFacetedSearchExpression<ProductProjection> lowestRating = reviewRatingsModel.lowestRating().is(String.valueOf(LOWEST_RATING));
  final ProductProjectionSearch productProjectionSearch = ProductProjectionSearch.ofStaged()
      .withQueryFilters(m -> m.id().is(product.getId()))
      .plusFacetedSearch(asList(count, averageRating, highestRating, lowestRating));
  assertEventually(() -> {
    final PagedSearchResult<ProductProjection> result = client().executeBlocking(productProjectionSearch);
    final List<ProductProjection> productProjectionList = result.getResults();
    assertThat(productProjectionList).isNotEmpty();
    assertThat(productProjectionList.get(0).getId()).isEqualTo(product.getId());
    assertThat(result.getFacetResult(count).getTotal()).as("count facet").isEqualTo(1L);
    assertThat(result.getFacetResult(averageRating).getTotal()).as("averageRating facet").isEqualTo(1L);
    assertThat(result.getFacetResult(highestRating).getTotal()).as("highestRating facet").isEqualTo(1L);
    assertThat(result.getFacetResult(lowestRating).getTotal()).as("lowestRating facet").isEqualTo(1L);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void simpleFacetsAreParsed() throws Exception {
  final TermFacetExpression<ProductProjection> facetExpr = TermFacetExpression.of("variants.attributes." + ATTR_NAME_COLOR);
  final ProductProjectionSearch search = ProductProjectionSearch.ofStaged().plusFacets(facetExpr);
  testResult(search, result -> {
    final TermFacetResult termFacetResult = result.getFacetResult(facetExpr);
    assertThat(termFacetResult.getMissing()).isGreaterThanOrEqualTo(3);
    assertThat(termFacetResult.getTotal()).isEqualTo(3);
    assertThat(termFacetResult.getOther()).isEqualTo(0);
    assertThat(termFacetResult.getTerms()).isEqualTo(asList(TermStats.of("blue", 2L), TermStats.of("red", 1L)));
  });
}
origin: commercetools/commercetools-jvm-sdk

private static void testTermStats(final TermFacetExpression<ProductProjection> facetExpr,
                 final Consumer<List<TermStats>> test) {
  final List<TermStats> termStats = executeSearchWithFacets(facetExpr).getFacetResult(facetExpr).getTerms();
  test.accept(termStats);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void termFacetsAreParsed() throws Exception {
  final TermFacetExpression<ProductProjection> facetExpr = PRODUCT_MODEL.allVariants().attribute().ofString(ATTR_NAME_COLOR).allTerms();
  final ProductProjectionSearch search = ProductProjectionSearch.ofStaged().plusFacets(facetExpr);
  testResult(search, result -> {
    final TermFacetResult termFacetResult = result.getFacetResult(facetExpr);
    assertThat(termFacetResult.getMissing()).isGreaterThanOrEqualTo(3);
    assertThat(termFacetResult.getTotal()).isEqualTo(3);
    assertThat(termFacetResult.getOther()).isEqualTo(0);
    assertThat(termFacetResult.getTerms()).isEqualTo(asList(TermStats.of("blue", 2L), TermStats.of("red", 1L)));
  });
}
origin: io.sphere.sdk.jvm/common

  public static <T> TermFacetResult<T> of(final long missing, final long total, final long other, final List<TermStats<T>> terms) {
    return new TermFacetResult<>(missing, total, other, terms);
  }
}
origin: commercetools/commercetools-jvm-sdk

private static void testResultWithTerms(final TermFacetedSearchExpression<ProductProjection> facetedSearchExpr,
                    final Consumer<List<String>> testFilter, final Consumer<List<TermStats>> testTerms) {
  final PagedSearchResult<ProductProjection> result = executeFacetedSearch(facetedSearchExpr, testFilter);
  testTerms.accept(result.getFacetResult(facetedSearchExpr).getTerms());
}
origin: commercetools/commercetools-jvm-sdk

  private static void testResult(final ProductProjectionSearch search,
                  final Consumer<List<String>> testFilter,
                  final Consumer<List<TermStats>> testColors,
                  final Consumer<List<TermStats>> testSizes) {
    assertEventually(Duration.ofSeconds(45), Duration.ofMillis(200), () -> {
      final PagedSearchResult<ProductProjection> result = executeSearch(search);
      testFilter.accept(toIds(result.getResults()));
      testColors.accept(result.getFacetResult(COLOR_FACETED_SEARCH).getTerms());
      testSizes.accept(result.getFacetResult(SIZE_FACETED_SEARCH).getTerms());
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void termFacetsSupportsAlias() throws Exception {
  final String allFacetAlias = "my-facet";
  final String blueFacetAlias = "my-blue-facet";
  final TermFacetExpression<ProductProjection> allFacetExpr = PRODUCT_MODEL.allVariants().attribute().ofString(ATTR_NAME_COLOR).withAlias(allFacetAlias).allTerms();
  final FilteredFacetExpression<ProductProjection> blueFacetExpr = PRODUCT_MODEL.allVariants().attribute().ofString(ATTR_NAME_COLOR).withAlias(blueFacetAlias).onlyTerm("blue");
  final ProductProjectionSearch search = ProductProjectionSearch.ofStaged()
      .plusFacets(allFacetExpr)
      .plusFacets(blueFacetExpr);
  testResult(search, result -> {
    final TermFacetResult allFacetResult = result.getFacetResult(allFacetExpr);
    final FilteredFacetResult blueFacetResult = result.getFilteredFacetResult(blueFacetAlias);
    assertThat(allFacetExpr.resultPath()).isEqualTo(allFacetAlias);
    assertThat(blueFacetExpr.resultPath()).isEqualTo(blueFacetAlias);
    assertThat(allFacetResult.getTerms()).isEqualTo(asList(TermStats.of("blue", 2L), TermStats.of("red", 1L)));
    assertThat(blueFacetResult.getCount()).isEqualTo(2);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void responseContainsTermFacetsForAttributes() throws Exception {
  final TermFacetExpression<ProductProjection> facetExpr = PRODUCT_MODEL.allVariants().attribute().ofString(ATTR_NAME_COLOR).allTerms();
  final ProductProjectionSearch search = ProductProjectionSearch.ofStaged().plusFacets(facetExpr);
  testResult(search, result ->
      assertThat(result.getFacetResult(facetExpr).getTerms()).containsOnly(TermStats.of("blue", 2L), TermStats.of("red", 1L)));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void facetSearchByScopedPriceDiscounted() {
  withProductOfPrices(asList(PriceDraft.of(EURO_20), PriceDraft.of(EURO_30).withCountry(DE)), product1 -> {
    withProductOfPrices(asList(PriceDraft.of(EURO_30), PriceDraft.of(EURO_40).withCountry(DE)), product2 -> {
      withProductOfPrices(asList(PriceDraft.of(EURO_40), PriceDraft.of(EURO_25).withCountry(DE)), product3 -> {
        final ProductDiscountDraft productDiscountDraft1 = discountDraftOfAbsoluteValue(product1, EURO_5);
        withProductDiscount(client(), productDiscountDraft1, productDiscount1 -> {
          assertEventually(s -> {
            final TermFacetExpression<ProductProjection> facetExpression = ProductProjectionSearchModel.of()
                .facet().allVariants().scopedPriceDiscounted().allTerms();
            final ProductProjectionSearch search = ProductProjectionSearch.ofStaged()
                .withPriceSelection(PriceSelection.of(EUR).withPriceCountry(DE))
                .plusQueryFilters(m -> m.id().isIn(asList(product1.getId(), product2.getId(), product3.getId())))
                .withFacets(facetExpression);
            final PagedSearchResult<ProductProjection> results = client().executeBlocking(search);
            assertThat(results.getResults()).hasSize(3);
            final List<TermStats> termStats = results.getFacetResult(facetExpression).getTerms();
            s.assertThat(termStats).containsOnly(
                TermStats.of(BOOL_TRUE, 1L),
                TermStats.of(BOOL_FALSE, 2L));
          });
        });
      });
    });
  });
}
io.sphere.sdk.searchTermFacetResult

Most used methods

  • <init>
  • getMissing
    The number of resources which have no value for the corresponding field. Use case: in a product sear
  • getOther
    The number of resources not included in the returned list of terms.
  • getTerms
    List of the different terms and amount of associated resources.
  • getTotal
    The number of resources matching some term in the facet.

Popular in Java

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • startActivity (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • String (java.lang)
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now