Package io.milvus.param.dml
Class SearchParam.Builder
- java.lang.Object
-
- io.milvus.param.dml.SearchParam.Builder
-
- Enclosing class:
- SearchParam
public static class SearchParam.Builder extends Object
Builder forSearchParamclass.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SearchParam.BuilderaddOutField(String fieldName)Specifies an output field (Optional).SearchParam.BuilderaddPartitionName(String partitionName)Adds a partition to specify search scope (Optional).SearchParambuild()Verifies parameters and creates a newSearchParaminstance.SearchParam.BuilderwithBFloat16Vectors(List<ByteBuffer> vectors)Sets the target vectors to search on BFloat16Vector field.SearchParam.BuilderwithBinaryVectors(List<ByteBuffer> vectors)Sets the target vectors to search on BinaryVector field.SearchParam.BuilderwithCollectionName(String collectionName)Sets the collection name.SearchParam.BuilderwithConsistencyLevel(ConsistencyLevelEnum consistencyLevel)ConsistencyLevel of consistency level.SearchParam.BuilderwithDatabaseName(String databaseName)Sets the database name.SearchParam.BuilderwithExpr(String expr)Sets expression to filter out entities before searching (Optional).SearchParam.BuilderwithFloat16Vectors(List<ByteBuffer> vectors)Sets the target vectors to search on Float16Vector field.SearchParam.BuilderwithFloatVectors(List<List<Float>> vectors)Sets the target vectors to search on FloatVector field.SearchParam.BuilderwithGroupByFieldName(String groupByFieldName)Sets field name to do grouping.SearchParam.BuilderwithGroupSize(Integer groupSize)Defines the max number of items for each group, the value must greater than zero.SearchParam.BuilderwithIgnoreGrowing(Boolean ignoreGrowing)Ignore the growing segments to get best search performance.SearchParam.BuilderwithLimit(Long limit)SearchParam.BuilderwithMetricType(MetricType metricType)Sets metric type of ANN searching.SearchParam.BuilderwithOutFields(List<String> outFields)Specifies output fields (Optional).SearchParam.BuilderwithParams(String params)Sets the search parameters specific to the index type.SearchParam.BuilderwithPartitionNames(List<String> partitionNames)Sets partition names list to specify search scope (Optional).SearchParam.BuilderwithRoundDecimal(Integer decimal)Specifies the decimal place of the returned results.SearchParam.BuilderwithSparseFloatVectors(List<SortedMap<Long,Float>> vectors)Sets the target vectors to search on SparseFloatVector field.SearchParam.BuilderwithStrictGroupSize(Boolean strictGroupSize)Whether to force the number of each group to be groupSize.SearchParam.BuilderwithTopK(Integer topK)Deprecated.SearchParam.BuilderwithVectorFieldName(String vectorFieldName)Sets target vector field by name.SearchParam.BuilderwithVectors(List<?> vectors)Deprecated.
-
-
-
Method Detail
-
withDatabaseName
public SearchParam.Builder withDatabaseName(String databaseName)
Sets the database name. database name can be nil.- Parameters:
databaseName- database name- Returns:
Builder
-
withCollectionName
public SearchParam.Builder withCollectionName(String collectionName)
Sets the collection name. Collection name cannot be empty or null.- Parameters:
collectionName- collection name- Returns:
Builder
-
withPartitionNames
public SearchParam.Builder withPartitionNames(List<String> partitionNames)
Sets partition names list to specify search scope (Optional).- Parameters:
partitionNames- partition names list- Returns:
Builder
-
withConsistencyLevel
public SearchParam.Builder withConsistencyLevel(ConsistencyLevelEnum consistencyLevel)
ConsistencyLevel of consistency level.- Parameters:
consistencyLevel- consistency level- Returns:
Builder
-
addPartitionName
public SearchParam.Builder addPartitionName(String partitionName)
Adds a partition to specify search scope (Optional).- Parameters:
partitionName- partition name- Returns:
Builder
-
withMetricType
public SearchParam.Builder withMetricType(MetricType metricType)
Sets metric type of ANN searching.- Parameters:
metricType- metric type- Returns:
Builder
-
withVectorFieldName
public SearchParam.Builder withVectorFieldName(String vectorFieldName)
Sets target vector field by name. Field name cannot be empty or null.- Parameters:
vectorFieldName- vector field name- Returns:
Builder
-
withTopK
@Deprecated public SearchParam.Builder withTopK(Integer topK)
Deprecated.Sets topK value of ANN search. withTopK() is deprecated, replaced by withLimit()- Parameters:
topK- topK value- Returns:
Builder
-
withLimit
public SearchParam.Builder withLimit(Long limit)
-
withExpr
public SearchParam.Builder withExpr(String expr)
Sets expression to filter out entities before searching (Optional).- Parameters:
expr- filtering expression- Returns:
Builder- See Also:
- Boolean Expression Rules
-
withOutFields
public SearchParam.Builder withOutFields(List<String> outFields)
Specifies output fields (Optional).- Parameters:
outFields- output fields- Returns:
Builder
-
addOutField
public SearchParam.Builder addOutField(String fieldName)
Specifies an output field (Optional).- Parameters:
fieldName- filed name- Returns:
Builder
-
withVectors
@Deprecated public SearchParam.Builder withVectors(List<?> vectors)
Deprecated.Sets the target vectors. Note: Deprecated in v2.4.0, for the reason that the sdk cannot know a ByteBuffer is a BinarVector or Float16Vector/BFloat16Vector. Replaced by withFloatVectors/withBinaryVectors/withFloat16Vectors/withBFloat16Vectors/withSparseFloatVectors. It still works for FloatVector/BinarVector/SparseVector, don't use it for Float16Vector/BFloat16Vector.- Parameters:
vectors- list of target vectors: if vector type is FloatVector, vectors is List of List Float; if vector type is BinaryVector, vectors is List of ByteBuffer; if vector type is SparseFloatVector, values is List of SortedMap[Long, Float];- Returns:
Builder
-
withFloatVectors
public SearchParam.Builder withFloatVectors(List<List<Float>> vectors)
Sets the target vectors to search on FloatVector field.- Parameters:
vectors- target vectors to search- Returns:
Builder
-
withBinaryVectors
public SearchParam.Builder withBinaryVectors(List<ByteBuffer> vectors)
Sets the target vectors to search on BinaryVector field.- Parameters:
vectors- target vectors to search- Returns:
Builder
-
withFloat16Vectors
public SearchParam.Builder withFloat16Vectors(List<ByteBuffer> vectors)
Sets the target vectors to search on Float16Vector field.- Parameters:
vectors- target vectors to search- Returns:
Builder
-
withBFloat16Vectors
public SearchParam.Builder withBFloat16Vectors(List<ByteBuffer> vectors)
Sets the target vectors to search on BFloat16Vector field.- Parameters:
vectors- target vectors to search- Returns:
Builder
-
withSparseFloatVectors
public SearchParam.Builder withSparseFloatVectors(List<SortedMap<Long,Float>> vectors)
Sets the target vectors to search on SparseFloatVector field.- Parameters:
vectors- target vectors to search- Returns:
Builder
-
withRoundDecimal
public SearchParam.Builder withRoundDecimal(Integer decimal)
Specifies the decimal place of the returned results.- Parameters:
decimal- how many digits after the decimal point- Returns:
Builder
-
withParams
public SearchParam.Builder withParams(String params)
Sets the search parameters specific to the index type.For example: IVF index, the search parameters can be "{\"nprobe\":10}" For more information: @see Index Selection
- Parameters:
params- extra parameters in json format- Returns:
Builder
-
withIgnoreGrowing
public SearchParam.Builder withIgnoreGrowing(Boolean ignoreGrowing)
Ignore the growing segments to get best search performance. Default is False. For the user case that don't require data visibility.- Parameters:
ignoreGrowing-Boolean.TRUEignore, Boolean.FALSE is not- Returns:
Builder
-
withGroupByFieldName
public SearchParam.Builder withGroupByFieldName(String groupByFieldName)
Sets field name to do grouping.- Parameters:
groupByFieldName- field name to do grouping- Returns:
Builder
-
withGroupSize
public SearchParam.Builder withGroupSize(Integer groupSize)
Defines the max number of items for each group, the value must greater than zero.- Parameters:
groupSize- the max number of items- Returns:
Builder
-
withStrictGroupSize
public SearchParam.Builder withStrictGroupSize(Boolean strictGroupSize)
Whether to force the number of each group to be groupSize. Set to false, milvus might return some groups with number of items less than groupSize.- Parameters:
strictGroupSize- whether to force the number of each group to be groupSize- Returns:
Builder
-
build
public SearchParam build() throws ParamException
Verifies parameters and creates a newSearchParaminstance.- Returns:
SearchParam- Throws:
ParamException
-
-