Skip to content

Commit 1b52655

Browse files
committed
Extracting out the std. attributes impl details
1 parent 8b65d23 commit 1b52655

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,18 @@ public SearchQuery withCategoryId(List<Integer> categoryId) {
5656

5757
/**
5858
* Combined with any of query/brand/category/store, limits results to products with specific attribute values
59+
* NOTE:
60+
* Prepends attribute filter key with "attr.", since product attributes are identified that way.
61+
* Examples of a few product attribute keys and values are:
62+
* 1. color -> red / blue / green / black
63+
* 2. size -> xs / s / m / l / xl
64+
* 3. gender -> mens / womens
65+
* A schema for the filterable keys and values isn't in place yet.
66+
* When the standard schema is published, the filterable keys for a category and the list of values for the same will be available.
5967
*/
6068
public SearchQuery withAttrFilter(String attrFilterKey, List<String> attrFilterValues) {
6169
for (String attrValue: attrFilterValues) {
62-
parameters.add(new BasicNameValuePair(attrFilterKey, attrValue));
70+
parameters.add(new BasicNameValuePair("attr."+attrFilterKey, attrValue));
6371
}
6472
return this;
6573
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public void testBasicQuery() {
5858
.withSortBy(SearchQuery.SortBy.PRICE_HIGH_TO_LOW)
5959
.withFacetBy(Arrays.asList("storeId", "brandId"))
6060
.withAttrFacetBy(Arrays.asList("attr.color", "attr.size"))
61-
.withAttrFilter("attr.color", Arrays.asList("black", "red"))
62-
.withAttrFilter("attr.size", Arrays.asList("xs"))
61+
.withAttrFilter("color", Arrays.asList("black", "red"))
62+
.withAttrFilter("size", Arrays.asList("xs"))
6363
.withPageNumber(5)
6464
.withPageSize(55)
6565
.withCountryCode("US")

0 commit comments

Comments
 (0)