Skip to content

Commit

Permalink
Merge pull request #80 from visenze/feature/rec
Browse files Browse the repository at this point in the history
[PS-2645] Recommendations API
  • Loading branch information
swVisenze authored Jul 30, 2021
2 parents 708ec44 + 98ddb8b commit f351e93
Show file tree
Hide file tree
Showing 16 changed files with 324 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc/ProductSearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ With the release of ViSenze's Catalog system, ViSearch Android SDK will now incl
- Aggregate search results on a product level instead of image level
- Consistent data type in API response with Catalog’s schema

> Current stable version: 2.0.1
> Current stable version: 2.1.0
> Minimum Android SDK Version: API 9, Android 2.3
Expand Down
2 changes: 1 addition & 1 deletion doc/ViSearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ViSearch is an API that provides accurate, reliable and scalable image search. V

The ViSearch Android SDK is an open source software to provide easy integration of ViSearch Search API with your Android mobile applications. It provides three search methods based on the ViSearch Search API - pre-indexed search, color search and upload search. For source code and references, please visit the [Github Repository](https://github.com/visenze/visearch-sdk-android).

>Current stable version: 2.0.1
>Current stable version: 2.1.0
>Minimum Android SDK Version: API 9, Android 2.3
Expand Down
6 changes: 3 additions & 3 deletions visearch-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ plugins {
}

def versionMajor = 2
def versionMinor = 0
def versionPatch = 1
version = '2.0.1'
def versionMinor = 1
def versionPatch = 0
version = '2.1.0'

android {
compileSdkVersion 28
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ public class IdSearchParams extends SearchParams {

private String imName;

// for recommendations
private String algorithm;

private Integer altLimit;

private String dedupBy;

public IdSearchParams() {
super();
}
Expand Down Expand Up @@ -45,10 +52,47 @@ public String getImageName() {
return imName;
}

public String getAlgorithm() {
return algorithm;
}

public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}

public Integer getAltLimit() {
return altLimit;
}

public void setAltLimit(Integer altLimit) {
this.altLimit = altLimit;
}

public String getDedupBy() {
return dedupBy;
}

public void setDedupBy(String dedupBy) {
this.dedupBy = dedupBy;
}

@Override
public Map<String, List<String> > toMap() {
Map<String, List<String> > map = super.toMap();
putStringInMap(map, "im_name", imName);

if (algorithm != null) {
putStringInMap(map, "algorithm", algorithm);
}

if (dedupBy != null) {
putStringInMap(map, "dedup_by", dedupBy);
}

if (altLimit != null) {
putStringInMap(map, "alt_limit", String.valueOf(altLimit));
}

return map;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
package com.visenze.visearch.android;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class ProductSearchByIdParams extends BaseProductSearchParams {

@Expose(deserialize = false, serialize = false)
private String productId;

@SerializedName("alt_limit")
private Integer altLimit;

public String getProductId() {
return productId;
}

public Integer getAltLimit() {
return altLimit;
}

public void setAltLimit(Integer altLimit) {
this.altLimit = altLimit;
}

public ProductSearchByIdParams(String productId) {
this.productId = productId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class ResultList {

private List<Facet> facets;

// recommendation related
private String algorithm;

public ResultList() {
imageResult = new ArrayList<ImageResult>();
queryInfo = new HashMap<String, String>();
Expand Down Expand Up @@ -220,4 +223,12 @@ public List<ObjectResult> getObjects() {
public void setObjects(List<ObjectResult> objects) {
this.objects = objects;
}

public String getAlgorithm() {
return algorithm;
}

public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gson.annotations.SerializedName;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
Expand All @@ -28,17 +29,21 @@ public class ImageResult {
@SerializedName("s3_url")
private String s3Url;

@SerializedName("alternatives")
private List<ImageResult> alternatives;

@SerializedName("tags")
private Map<String, Object> tags;

public ImageResult() {
this.fieldList = new HashMap<String, String>();
}

public ImageResult(String imageName, String imageUrl, Float score, Map<String, String> filedList) {
public ImageResult(String imageName, String imageUrl, Float score, Map<String, String> fieldList) {
this.imageName = imageName;
this.imageUrl = imageUrl;
this.score = score;
this.fieldList = filedList;
this.fieldList = fieldList;
}

/**
Expand Down Expand Up @@ -91,6 +96,14 @@ public String getS3Url() {
return s3Url;
}

public List<ImageResult> getAlternatives() {
return alternatives;
}

public Map<String, Object> getTags() {
return tags;
}

public void setImageName(String imageName) {
this.imageName = imageName;
}
Expand All @@ -113,4 +126,12 @@ public void setFieldList(Map<String, String> fieldList) {
public void setS3Url(String s3Url) {
this.s3Url = s3Url;
}

public void setAlternatives(List<ImageResult> alternatives) {
this.alternatives = alternatives;
}

public void setTags(Map<String, Object> tags) {
this.tags = tags;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.util.List;
import java.util.Map;

public class Product {
Expand Down Expand Up @@ -35,6 +36,11 @@ public class Product {
@Expose(deserialize = false, serialize = false)
private Box box;

@SerializedName("tags")
private Map<String, Object> tags;

@SerializedName("alternatives")
private List<Product> alternatives;

public String getProductId() {
return productId;
Expand Down Expand Up @@ -112,4 +118,20 @@ private Box parseBox(int[] boxData) {

return null;
}

public Map<String, Object> getTags() {
return tags;
}

public void setTags(Map<String, Object> tags) {
this.tags = tags;
}

public List<Product> getAlternatives() {
return alternatives;
}

public void setAlternatives(List<Product> alternatives) {
this.alternatives = alternatives;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public class ProductResponse {
@SerializedName("reqid")
private String reqId;

@SerializedName("alt_limit")
private Integer altLimit;

@SerializedName("strategy")
private Strategy strategy;

public String getStatus() {
return status;
}
Expand Down Expand Up @@ -149,4 +155,20 @@ public String getReqId() {
public void setReqId(String reqId) {
this.reqId = reqId;
}

public Integer getAltLimit() {
return altLimit;
}

public void setAltLimit(Integer altLimit) {
this.altLimit = altLimit;
}

public Strategy getStrategy() {
return strategy;
}

public void setStrategy(Strategy strategy) {
this.strategy = strategy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public class ResponseData {
@SerializedName("facets")
private List<Facet> facets;

@SerializedName("algorithm")
private String algorithm;

public void setStatus(String status) {
this.status = status;
}
Expand Down Expand Up @@ -135,6 +138,10 @@ public void setFacets(List<Facet> facets) {
this.facets = facets;
}

public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}

public List<Facet> getFacets() {
return facets;
}
Expand Down Expand Up @@ -178,6 +185,11 @@ public List<ImageResult> getResults() {
public List<ObjectResult> getObjects() {
return objects;
}

public String getAlgorithm() {
return algorithm;
}

public ResultList getResultList() {
ResultList resultList = new ResultList();
if(error != null && error.length > 0) {
Expand All @@ -189,6 +201,7 @@ public ResultList getResultList() {
resultList.setLimit(limit);
resultList.setTransId(transId);
resultList.setQueryInfo(qinfo);
resultList.setAlgorithm(algorithm);

resultList.setImageList(results);
resultList.setObjects(objects);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.visenze.visearch.android.model;

import com.google.gson.annotations.SerializedName;

public class Strategy {

@SerializedName("id")
private Integer id;

@SerializedName("name")
private String name;

@SerializedName("algorithm")
private String algorithm;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getAlgorithm() {
return algorithm;
}

public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface APIService {
Call<ResponseData> search(@HeaderMap Map<String, String> headers, @QueryMap RetrofitQueryMap query);

@Retry
@GET("recommendation")
@GET("recommendations")
Call<ResponseData> recommendation(@HeaderMap Map<String, String> headers, @QueryMap RetrofitQueryMap query);

@Retry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class SearchService {

public final static String ID_SEARCH = "search";
public final static String RECOMMENDATION = "recommendation";
public final static String RECOMMENDATION = "recommendations";
public final static String COLOR_SEARCH = "colorsearch";
public final static String UPLOAD_SEARCH = "uploadsearch";
public final static String DISCOVER_SEARCH = "discoversearch";
Expand Down
Loading

0 comments on commit f351e93

Please sign in to comment.