Skip to content

Commit 0eba062

Browse files
committed
Adds support for faceting by product attributes
1 parent e9d53cc commit 0eba062

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/main/java/com/indix/query/SearchQuery.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ public SearchQuery withFacetBy(List<String> facetBy) {
224224
return this;
225225
}
226226

227+
/**
228+
* Facet by product attribute values
229+
*/
230+
public SearchQuery withAttrFacetBy(List<String> attrFacetBy) {
231+
for (String attrFacet : attrFacetBy) {
232+
parameters.add(new BasicNameValuePair("attrFacetBy", attrFacet));
233+
}
234+
return this;
235+
}
236+
227237
/**
228238
* Specifies the page number of the result set to return. 10 results per page.
229239
*/

src/test/java/com/indix/query/SearchQueryTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public void testBasicQuery() {
4141
expectedValue.add(new BasicNameValuePair("sortBy", "PRICE_HIGH_TO_LOW"));
4242
expectedValue.add(new BasicNameValuePair("facetBy", "storeId"));
4343
expectedValue.add(new BasicNameValuePair("facetBy", "brandId"));
44+
expectedValue.add(new BasicNameValuePair("attrFacetBy", "attr.color"));
45+
expectedValue.add(new BasicNameValuePair("attrFacetBy", "attr.size"));
4446
expectedValue.add(new BasicNameValuePair("attr.color", "black"));
4547
expectedValue.add(new BasicNameValuePair("attr.color", "red"));
4648
expectedValue.add(new BasicNameValuePair("attr.size", "xs"));
@@ -55,6 +57,7 @@ public void testBasicQuery() {
5557
.withSku("sku1")
5658
.withSortBy(SearchQuery.SortBy.PRICE_HIGH_TO_LOW)
5759
.withFacetBy(Arrays.asList("storeId", "brandId"))
60+
.withAttrFacetBy(Arrays.asList("attr.color", "attr.size"))
5861
.withAttrFilter("attr.color", Arrays.asList("black", "red"))
5962
.withAttrFilter("attr.size", Arrays.asList("xs"))
6063
.withPageNumber(5)

0 commit comments

Comments
 (0)