Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sdk-core/src/main/java/io/milvus/param/ParamUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,9 @@ public static HybridSearchRequest convertHybridSearchParam(@NonNull HybridSearch
// set ranker
BaseRanker ranker = requestParam.getRanker();
Map<String, String> props = ranker.getProperties();
props.put("limit", String.format("%d", requestParam.getTopK()));
props.put("round_decimal", String.format("%d", requestParam.getRoundDecimal()));
props.put(Constant.LIMIT, String.format("%d", requestParam.getTopK()));
props.put(Constant.ROUND_DECIMAL, String.format("%d", requestParam.getRoundDecimal()));
props.put(Constant.OFFSET, String.format("%d", requestParam.getOffset()));
List<KeyValuePair> propertiesList = ParamUtils.AssembleKvPair(props);
if (CollectionUtils.isNotEmpty(propertiesList)) {
propertiesList.forEach(builder::addRankParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class HybridSearchParam {
private final BaseRanker ranker;
private final int topK;
private final List<String> outFields;
private final long offset;
private final int roundDecimal;
private final ConsistencyLevelEnum consistencyLevel;

Expand All @@ -59,6 +60,7 @@ private HybridSearchParam(@NonNull Builder builder) {
this.ranker = builder.ranker;
this.topK = builder.topK;
this.outFields = builder.outFields;
this.offset = builder.offset;
this.roundDecimal = builder.roundDecimal;
this.consistencyLevel = builder.consistencyLevel;
this.groupByFieldName = builder.groupByFieldName;
Expand All @@ -81,6 +83,7 @@ public static class Builder {
private BaseRanker ranker = null;
private Integer topK;
private final List<String> outFields = Lists.newArrayList();
private Long offset = 0L;
private Integer roundDecimal = -1;
private ConsistencyLevelEnum consistencyLevel = null;
private String groupByFieldName = null;
Expand Down Expand Up @@ -204,6 +207,17 @@ public Builder addOutField(@NonNull String fieldName) {
return this;
}

/**
* Specifies the offset place of the returned results.
*
* @param offset the offset position
* @return <code>Builder</code>
*/
public Builder withOffset(@NonNull Long offset) {
this.offset = offset;
return this;
}

/**
* Specifies the decimal place of the returned results.
*
Expand All @@ -218,7 +232,7 @@ public Builder withRoundDecimal(@NonNull Integer decimal) {
/**
* Groups the results by a scalar field name.
*
* @param fieldName a scalar field name
* @param groupByFieldName a scalar field name
* @return <code>Builder</code>
*/
public Builder withGroupByFieldName(@NonNull String groupByFieldName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class HybridSearchReq
private BaseRanker ranker;
private int topK;
private List<String> outFields;
private long offset;
@Builder.Default
private int roundDecimal = -1;
@Builder.Default
Expand All @@ -46,4 +47,5 @@ public class HybridSearchReq
private String groupByFieldName;
private Integer groupSize;
private Boolean strictGroupSize;

}
5 changes: 3 additions & 2 deletions sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,9 @@ public HybridSearchRequest ConvertToGrpcHybridSearchRequest(HybridSearchReq requ
}

Map<String, String> props = ranker.getProperties();
props.put("limit", String.format("%d", request.getTopK()));
props.put("round_decimal", String.format("%d", request.getRoundDecimal()));
props.put(Constant.LIMIT, String.format("%d", request.getTopK()));
props.put(Constant.ROUND_DECIMAL, String.format("%d", request.getRoundDecimal()));
props.put(Constant.OFFSET, String.format("%d", request.getOffset()));
List<KeyValuePair> propertiesList = ParamUtils.AssembleKvPair(props);
if (CollectionUtils.isNotEmpty(propertiesList)) {
propertiesList.forEach(builder::addRankParams);
Expand Down
Loading