Skip to content

Commit

Permalink
add group results
Browse files Browse the repository at this point in the history
  • Loading branch information
thehung111 committed Apr 26, 2023
1 parent a65f93a commit 61e146e
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 5 deletions.
6 changes: 3 additions & 3 deletions 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.3.1
> Current stable version: 2.3.2
> Minimum Android SDK Version: API 9, Android 2.3
Expand Down Expand Up @@ -65,12 +65,12 @@ include the dependency in your project using gradle. Please change the version t

```gradle
implementation 'com.github.visenze:visenze-tracking-android:0.2.3'
implementation 'com.github.visenze:visearch-sdk-android:2.3.1'
implementation 'com.github.visenze:visearch-sdk-android:2.3.2'
```

### 1.3 Add User Permissions

Our SDK additionally needs these user permissions to work. Add the following declarations to the `AndroidManifest.xml` file.
Our SDK additionally needs these user permissions to work. Add the following declarations to the `AndroidManifest.xml` file. Note that camera permission is optional.

```xml
<?xml version="1.0" encoding="utf-8"?>
Expand Down
4 changes: 2 additions & 2 deletions 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.3.1
>Current stable version: 2.3.2
>Minimum Android SDK Version: API 9, Android 2.3
Expand Down Expand Up @@ -81,7 +81,7 @@ include the dependency in your project using gradle. Please change the version t

```gradle
implementation 'com.github.visenze:visenze-tracking-android:0.2.3'
implementation 'com.github.visenze:visearch-sdk-android:2.3.1'
implementation 'com.github.visenze:visearch-sdk-android:2.3.2'
```

### 1.3 Add User Permissions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.visenze.visearch.android;

import com.visenze.visearch.android.model.Facet;
import com.visenze.visearch.android.model.GroupSearchResult;
import com.visenze.visearch.android.model.ImageResult;
import com.visenze.visearch.android.model.ObjectResult;
import com.visenze.visearch.android.model.ProductType;
Expand Down Expand Up @@ -58,6 +59,8 @@ public class ResultList {

private List<SetInfo> setInfoList;

private List<GroupSearchResult> groupResults;

public ResultList() {
imageResult = new ArrayList<ImageResult>();
queryInfo = new HashMap<String, String>();
Expand Down Expand Up @@ -252,4 +255,12 @@ public List<SetInfo> getSetInfoList() {
public void setSetInfoList(List<SetInfo> setInfoList) {
this.setInfoList = setInfoList;
}

public List<GroupSearchResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupSearchResult> groupResults) {
this.groupResults = groupResults;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.visenze.visearch.android.model;

import com.google.gson.annotations.SerializedName;

import java.util.List;

public class GroupProductResult {

@SerializedName("group_by_value")
private String groupByValue;

@SerializedName("result")
private List<Product> products;

public String getGroupByValue() {
return groupByValue;
}

public void setGroupByValue(String groupByValue) {
this.groupByValue = groupByValue;
}

public List<Product> getProducts() {
return products;
}

public void setProducts(List<Product> products) {
this.products = products;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.visenze.visearch.android.model;

import com.google.gson.annotations.SerializedName;

import java.util.List;

public class GroupSearchResult {

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

@SerializedName("group_by_value")
private String groupByValue;

public List<ImageResult> getResult() {
return result;
}

public void setResult(List<ImageResult> result) {
this.result = result;
}

public String getGroupByValue() {
return groupByValue;
}

public void setGroupByValue(String groupByValue) {
this.groupByValue = groupByValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class ObjectResult extends ProductType {
@SerializedName("facets")
private List<Facet> facets;

@SerializedName("group_results")
private List<GroupSearchResult> groupResults;

public List<ImageResult> getResult() {
return result;
}
Expand Down Expand Up @@ -81,4 +84,12 @@ public List<Facet> getFacets() {
public void setFacets(List<Facet> facets) {
this.facets = facets;
}

public List<GroupSearchResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupSearchResult> groupResults) {
this.groupResults = groupResults;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public class ProductObject extends ProductType {
@SerializedName("result")
private List<Product> result;

@SerializedName("group_results")
private List<GroupProductResult> groupResults;

@SerializedName("total")
private Integer total;

Expand Down Expand Up @@ -81,4 +84,12 @@ public List<Facet> getFacets() {
public void setFacets(List<Facet> facets) {
this.facets = facets;
}

public List<GroupProductResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupProductResult> groupResults) {
this.groupResults = groupResults;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class ProductResponse {
@SerializedName("result")
private List<Product> products;

@SerializedName("group_results")
private List<GroupProductResult> groupResults;

@SerializedName("objects")
private List<ProductObject> objects;

Expand Down Expand Up @@ -212,4 +215,12 @@ public List<SetInfo> getSetInfoList() {
public void setSetInfoList(List<SetInfo> setInfoList) {
this.setInfoList = setInfoList;
}

public List<GroupProductResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupProductResult> groupResults) {
this.groupResults = groupResults;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class ResponseData {
@SerializedName("result")
private List<ImageResult> results;

@SerializedName("group_results")
private List<GroupSearchResult> groupResults;

@SerializedName("product_types")
private List<ProductType> productTypes;

Expand Down Expand Up @@ -212,6 +215,14 @@ public List<String> getExcludedImNames() {
return excludedImNames;
}

public List<GroupSearchResult> getGroupResults() {
return groupResults;
}

public void setGroupResults(List<GroupSearchResult> groupResults) {
this.groupResults = groupResults;
}

public ResultList getResultList() {
ResultList resultList = new ResultList();
if(error != null && error.length > 0) {
Expand All @@ -238,6 +249,7 @@ public ResultList getResultList() {
resultList.setFacets(facets);
resultList.setExcludedImNames(excludedImNames);
resultList.setSetInfoList(setInfoList);
resultList.setGroupResults(groupResults);

return resultList;
}
Expand Down

0 comments on commit 61e146e

Please sign in to comment.