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

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void throwsExceptionOnAccessingWrongExpression() throws Exception {
  final FilteredFacetExpression<Object> facet = FilteredFacetExpression.of("some wrong facet");
  assertThat(facet.expression()).isEqualTo("some wrong facet");
  assertThatThrownBy(() -> facet.attributePath()).isInstanceOf(IllegalArgumentException.class);
  assertThatThrownBy(() -> facet.value()).isInstanceOf(IllegalArgumentException.class);
  assertThatThrownBy(() -> facet.alias()).isInstanceOf(IllegalArgumentException.class);
  assertThatThrownBy(() -> facet.resultPath()).isInstanceOf(IllegalArgumentException.class);
}
origin: io.sphere.sdk.jvm/common

  public FilteredFacetExpression<T, V> only(final Iterable<V> values) {
    return new FilteredFacetExpression<>(this, typeSerializer, values, alias);
  }
}
origin: io.sphere.sdk.jvm/common

  @Override
  public boolean equals(Object o) {
    return o != null && o instanceof FacetExpression && toSphereFacet().equals(((FacetExpression) o).toSphereFacet());
  }
}
origin: io.sphere.sdk.jvm/common

  public Optional<FilteredFacetResult> getFilteredFacetResult(final FilteredFacetExpression<T, ?> facetExpression) {
    return getFacetResult(facetExpression.resultPath()).map(facetResult -> {
      if (facetResult instanceof FilteredFacetResult) {
        return (FilteredFacetResult) facetResult;
      } else {
        // TODO Use another type of exception once exception task is finished
        throw new RuntimeException("Facet result is not of type FilterFacetResult: " + facetResult);
      }
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void usesAlias() throws Exception {
  final RangeTermFacetSearchModel<ProductProjection, BigDecimal> path = FACET_ATTR.ofNumber("size");
  assertThat(path.withAlias("my-facet").allTerms().expression()).isEqualTo("variants.attributes.size as my-facet");
  assertThat(path.withAlias("my-facet").onlyTerm(valueOf(38)).expression()).isEqualTo("variants.attributes.size:38 as my-facet");
  assertThat(path.withAlias("my-facet").onlyLessThan(valueOf(38)).expression()).isEqualTo("variants.attributes.size:range(* to 38) as my-facet");
}
origin: commercetools/commercetools-jvm-sdk

public FilteredFacetResult getFacetResult(final FilteredFacetExpression<T> facetExpression) {
  return getFilteredFacetResult(facetExpression.resultPath());
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void buildsFilteredFacetExpressionWithAlias() throws Exception {
  final FilteredFacetExpression<Object> facet = FilteredFacetExpression.of(ATTRIBUTE_PATH + TERM_VALUE + AS_ALIAS);
  assertThat(facet.expression()).isEqualTo(ATTRIBUTE_PATH + TERM_VALUE + AS_ALIAS);
  assertThat(facet.attributePath()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.value()).isEqualTo(TERM_VALUE);
  assertThat(facet.alias()).isEqualTo(ALIAS);
  assertThat(facet.resultPath()).isEqualTo(ALIAS);
}
origin: commercetools/commercetools-jvm-sdk

private <T> void testPagedSearchResult(final Consumer<PagedSearchResult<T>> test) {
  final Map<String, FacetResult> facets = new HashMap<>();
  facets.put(TERM_FACET_EXPR.resultPath(), TERM_FACET_RESULT);
  facets.put(RANGE_FACET_EXPR.resultPath(), RANGE_FACET_RESULT);
  facets.put(FILTERED_FACET_EXPR.resultPath(), FILTERED_FACET_RESULT);
  final PagedSearchResult<T> result = pagedSearchResult(facets);
  test.accept(result);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void buildsFilteredFacetExpression() throws Exception {
  final FilteredFacetExpression<Object> facet = FilteredFacetExpression.of(ATTRIBUTE_PATH + TERM_VALUE);
  assertThat(facet.expression()).isEqualTo(ATTRIBUTE_PATH + TERM_VALUE);
  assertThat(facet.attributePath()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.value()).isEqualTo(TERM_VALUE);
  assertThat(facet.alias()).isNull();
  assertThat(facet.resultPath()).isEqualTo(ATTRIBUTE_PATH);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void termFacetResult() throws Exception {
  testPagedSearchResult(result -> {
    assertThat(result.getFacetResult(TERM_FACET_EXPR)).isEqualTo(TERM_FACET_RESULT);
    assertThat(result.getTermFacetResult("non-existent")).isNull();
    assertThatThrownBy(() -> result.getTermFacetResult(RANGE_FACET_EXPR.resultPath()))
        .isInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> result.getTermFacetResult(FILTERED_FACET_EXPR.resultPath()))
        .isInstanceOf(IllegalArgumentException.class);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void buildsFilteredFacetExpression() throws Exception {
  final FilteredFacetExpression<Object> facet = TermFacetSearchModel.of(ATTRIBUTE_PATH, ofString()).onlyTerm(TERMS);
  assertThat(facet.expression()).isEqualTo(ATTRIBUTE_PATH + TERM_VALUE);
  assertThat(facet.attributePath()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.value()).isEqualTo(TERM_VALUE);
  assertThat(facet.alias()).isNull();
  assertThat(facet.resultPath()).isEqualTo(ATTRIBUTE_PATH);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void rangeFacetResult() throws Exception {
  testPagedSearchResult(result -> {
    assertThat(result.getFacetResult(RANGE_FACET_EXPR)).isEqualTo(RANGE_FACET_RESULT);
    assertThat(result.getRangeFacetResult("non-existent")).isNull();
    assertThatThrownBy(() -> result.getRangeFacetResult(TERM_FACET_EXPR.resultPath()))
        .isInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> result.getRangeFacetResult(FILTERED_FACET_EXPR.resultPath()))
        .isInstanceOf(IllegalArgumentException.class);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void buildsFilteredFacetExpressionWithAlias() throws Exception {
  final FilteredFacetExpression<Object> facet = TermFacetSearchModel.of(ATTRIBUTE_PATH, ofString()).withAlias(ALIAS).onlyTerm(TERMS);
  assertThat(facet.expression()).isEqualTo(ATTRIBUTE_PATH + TERM_VALUE + AS_ALIAS);
  assertThat(facet.attributePath()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.value()).isEqualTo(TERM_VALUE);
  assertThat(facet.alias()).isEqualTo(ALIAS);
  assertThat(facet.resultPath()).isEqualTo(ALIAS);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void filteredFacetsSupportsAlias() throws Exception {
  final String alias = "my-facet";
  final FilteredFacetExpression<ProductProjection> facetExpr = PRODUCT_MODEL.allVariants().attribute().ofString(ATTR_NAME_COLOR).withAlias(alias).onlyTerm("blue");
  final ProductProjectionSearch search = ProductProjectionSearch.ofStaged().plusFacets(facetExpr);
  testResult(search, result -> {
    assertThat(facetExpr.resultPath()).isEqualTo(alias);
    assertThat(result.getFacetResult(facetExpr).getCount()).isEqualTo(2);
  });
}
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);
  });
}
io.sphere.sdk.searchFilteredFacetExpression

Javadoc

Filtered facets calculate statistical count for all given values. Example: variants.attributes.color:"red","green"

Most used methods

  • resultPath
  • expression
  • <init>
  • alias
  • attributePath
  • of
  • toSphereFacet
  • value

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • orElseThrow (Optional)
  • Point (java.awt)
    A point representing a location in (x, y) coordinate space, specified in integer precision.
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
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