public TermFacetedSearchSearchModel<ProductProjection> ofBooleanSet(final String attributeName) { return ofBoolean(attributeName); }
public RangeTermFacetedSearchSearchModel<ProductProjection> ofDateSet(final String attributeName) { return ofDate(attributeName); }
public RangeTermFacetedSearchSearchModel<ProductProjection> ofDateTimeSet(final String attributeName) { return ofDateTime(attributeName); }
@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))); }
public MoneyFacetedSearchSearchModel<ProductProjection> ofMoneySet(final String attributeName) { return ofMoney(attributeName); }
public RangeTermFacetedSearchSearchModel<ProductProjection> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
public LocalizedEnumFacetedSearchSearchModel<ProductProjection> ofLocalizedEnumSet(final String attributeName) { return ofLocalizedEnum(attributeName); }
public EnumFacetedSearchSearchModel<ProductProjection> ofEnumSet(final String attributeName) { return ofEnum(attributeName); }
public LocalizedStringFacetedSearchSearchModel<ProductProjection> ofLocalizedStringSet(final String attributeName) { return ofLocalizedString(attributeName); }
public ReferenceFacetedSearchSearchModel<ProductProjection> ofReferenceSet(final String attributeName) { return ofReference(attributeName); } }
public TermFacetedSearchSearchModel<ProductProjection> ofStringSet(final String attributeName) { return ofString(attributeName); }
public MoneyFacetedSearchSearchModel<ProductProjection> ofMoneySet(final String attributeName) { return ofMoney(attributeName); }
public RangeTermFacetedSearchSearchModel<ProductProjection> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
public LocalizedEnumFacetedSearchSearchModel<ProductProjection> ofLocalizedEnumSet(final String attributeName) { return ofLocalizedEnum(attributeName); }
public EnumFacetedSearchSearchModel<ProductProjection> ofEnumSet(final String attributeName) { return ofEnum(attributeName); }
public LocalizedStringFacetedSearchSearchModel<ProductProjection> ofLocalizedStringSet(final String attributeName) { return ofLocalizedString(attributeName); }
public ReferenceFacetedSearchSearchModel<ProductProjection> ofReferenceSet(final String attributeName) { return ofReference(attributeName); } }
public TermFacetedSearchSearchModel<ProductProjection> ofStringSet(final String attributeName) { return ofString(attributeName); }
@Test public void facetedSearchOnMoneyAmountRangedAttributes() throws Exception { testResultWithRange(PRODUCT_MODEL.allVariants().attribute().ofMoney(ATTR_NAME_MONEY).centAmount().isBetween(atMost(toCents(MONEY_500_EUR).toString())), 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("50000.0"); assertThat(rangeStats.getMax()).isEqualTo("100000.0"); }); }
@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"); }); }