Skip to content

Commit

Permalink
Merge pull request #100 from visenze/feature/non_product_based_recs
Browse files Browse the repository at this point in the history
[API-9725] add non_product_based_recs param
  • Loading branch information
thehung111 authored Jul 25, 2023
2 parents f471958 + 375e4bb commit b81ae0b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.visenze</groupId>
<artifactId>visearch-java-sdk</artifactId>
<name>ViSearch Java SDK</name>
<version>1.13.6</version>
<version>1.13.7</version>
<packaging>jar</packaging>
<url>https://github.com/visenze/visearch-sdk-java</url>
<description>ViSearch Java SDK</description>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/visenze/productsearch/param/SearchByIdParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class SearchByIdParam extends BaseProductSearchParam {

protected Optional<Boolean> showExcludedPids = Optional.absent();

protected Optional<Boolean> nonProductBasedRecs = Optional.absent();

protected Optional<Integer> setLimit = Optional.absent();
protected Optional<Boolean> useSetBasedCtl = Optional.absent();

Expand Down Expand Up @@ -79,6 +81,7 @@ public Multimap<String, String> toMultimap() {
putIfPresent(multimap, strategyId, STRATEGY_ID);
putIfPresent(multimap, showExcludedPids, SHOW_EXCLUDED_PIDS);
putIfPresent(multimap, showPinnedPids, SHOW_PINNED_PIDS);
putIfPresent(multimap, nonProductBasedRecs, "non_product_based_recs");

putIfPresent(multimap, useSetBasedCtl, USE_SET_BASED_CTL);
putIfPresent(multimap, setLimit, SET_LIMIT);
Expand Down Expand Up @@ -163,6 +166,14 @@ public void setShowPinnedPids(Boolean showPinnedPids) {
this.showPinnedPids = Optional.fromNullable(showPinnedPids);
}

public Boolean getNonProductBasedRecs() {
return nonProductBasedRecs.orNull();
}

public void setNonProductBasedRecs(Boolean nonProductBasedRecs) {
this.nonProductBasedRecs = Optional.fromNullable(nonProductBasedRecs);
}

public Boolean getShowExcludedPids() {
return showExcludedPids.orNull();
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/visenze/visearch/RecommendSearchParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class RecommendSearchParams extends SearchParams {
private List<String> boxList;
private List<String> categoryList;

// for SBR only, if true, will ignore the query imName, and only check the session
private Boolean nonProductBasedRecs;

public RecommendSearchParams(String imName) {
super(imName);
}
Expand All @@ -50,6 +53,7 @@ public Multimap<String, String> toMap() {
putIfNotNull(map, "use_set_based_ctl", useSetBasedCtl);
putIfNotNull(map, "set_limit", setLimit);
putIfNotNull(map, SHOW_BEST_PRODUCT_IMAGES, showBestProductImages );
putIfNotNull(map, "non_product_based_recs", nonProductBasedRecs);

if (boxList != null) {
for(String box: boxList) {
Expand Down Expand Up @@ -167,4 +171,12 @@ public List<String> getCategoryList() {
public void setCategoryList(List<String> categoryList) {
this.categoryList = categoryList;
}

public Boolean getNonProductBasedRecs() {
return nonProductBasedRecs;
}

public void setNonProductBasedRecs(Boolean nonProductBasedRecs) {
this.nonProductBasedRecs = nonProductBasedRecs;
}
}
5 changes: 3 additions & 2 deletions src/main/java/com/visenze/visearch/SearchParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public SearchParams(String imName) {
}

private SearchParams setImName(String imName) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(imName), "im_name must not be null or empty for pre-indexed search.");
this.imName = imName;
return this;
}
Expand All @@ -26,7 +25,9 @@ public String getImName() {
@Override
public Multimap<String, String> toMap() {
Multimap<String, String> map = super.toMap();
map.put("im_name", imName);
if (imName != null) {
map.put("im_name", imName);
}
return map;
}
}

0 comments on commit b81ae0b

Please sign in to comment.