public RangeTermFacetedSearchSearchModel<ProductProjection> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
public RangeTermFacetedSearchSearchModel<ProductProjection> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
@Test public void facetedSearchOnNumberRangedAttributes() throws Exception { testResultWithRange(PRODUCT_MODEL.allVariants().attribute().ofNumber(ATTR_NAME_NUMBER).isBetween(atMost(NUMBER_5.toPlainString())), ids -> assertThat(ids).containsOnly(product1.getId()), rangeStats -> { assertThat(rangeStats.getLowerEndpoint()).isEqualTo(null); assertThat(rangeStats.getUpperEndpoint()).isEqualTo(null); assertThat(rangeStats.getCount()).isEqualTo(2L); assertThat(rangeStats.getMin()).isEqualTo("5.0"); assertThat(rangeStats.getMax()).isEqualTo("10.0"); }); }
@Test public void facetedSearchOnNumberAttributes() throws Exception { testResultWithTerms(PRODUCT_MODEL.allVariants().attribute().ofNumber(ATTR_NAME_NUMBER).is(NUMBER_5.toPlainString()), ids -> assertThat(ids).containsOnly(product1.getId()), termStats -> assertThat(termStats).containsOnly( TermStats.of("5.0", 1L), TermStats.of("10.0", 1L))); }
@Test public void facetedSearchExample() throws Exception { final ProductAttributeFacetedSearchSearchModel attributeModel = ProductProjectionSearchModel.of().facetedSearch().allVariants().attribute(); final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .plusFacetedSearch(attributeModel.ofNumber(ATTR_NAME_SIZE).allTerms()) .plusFacetedSearch(attributeModel.ofString(ATTR_NAME_COLOR).is("red")); testResult(search, ids -> assertThat(ids).containsOnly(product2.getId()), colors -> assertThat(colors).containsOnly(TermStats.of("blue", 2L), TermStats.of("red", 1L)), sizes -> assertThat(sizes).containsOnly(TermStats.of("36.0", 1L))); }