# SearchParam.Builder

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 java.lang.Object

Builder for `SearchParam` class.

### Method Summary

All Methods Instance Methods Concrete Methods
`SearchParam.Builder` `addOutField​(@NonNull java.lang.String fieldName)` Specifies an output field (Optional).
`SearchParam.Builder` `addPartitionName​(@NonNull java.lang.String partitionName)` Adds a partition to specify search scope (Optional).
`SearchParam` `build()` Verifies parameters and creates a new `SearchParam` instance.
`SearchParam.Builder` `withCollectionName​(@NonNull java.lang.String collectionName)` Sets the collection name.
`SearchParam.Builder` `withConsistencyLevel​(ConsistencyLevelEnum consistencyLevel)` ConsistencyLevel of consistency level.
`SearchParam.Builder` `withExpr​(@NonNull java.lang.String expr)` Sets expression to filter out entities before searching (Optional).
`SearchParam.Builder` `withIgnoreGrowing​(@NonNull java.lang.Boolean ignoreGrowing)` Ignore the growing segments to get best search performance.
`SearchParam.Builder` `withMetricType​(@NonNull MetricType metricType)` Sets metric type of ANN searching.
`SearchParam.Builder` `withOutFields​(@NonNull java.util.List<java.lang.String> outFields)` Specifies output fields (Optional).
`SearchParam.Builder` `withParams​(@NonNull java.lang.String params)` Sets the search parameters specific to the index type.
`SearchParam.Builder` `withPartitionNames​(@NonNull java.util.List<java.lang.String> partitionNames)` Sets partition names list to specify search scope (Optional).
`SearchParam.Builder` `withRoundDecimal​(@NonNull java.lang.Integer decimal)` Specifies the decimal place of the returned results.
`SearchParam.Builder` `withTopK​(@NonNull java.lang.Integer topK)` Sets topK value of ANN search.
`SearchParam.Builder` `withVectorFieldName​(@NonNull java.lang.String vectorFieldName)` Sets target vector field by name.
`SearchParam.Builder` `withVectors​(@NonNull java.util.List<?> vectors)` Sets the target vectors.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### withCollectionName

    public SearchParam.Builder withCollectionName​(@NonNull
                                                  @NonNull java.lang.String collectionName)

Sets the collection name. Collection name cannot be empty or null.

Parameters:
  `collectionName` - collection name
Returns:
  `Builder`

#### withPartitionNames

    public SearchParam.Builder withPartitionNames​(@NonNull
                                                  @NonNull java.util.List<java.lang.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​(@NonNull
                                                @NonNull java.lang.String partitionName)

Adds a partition to specify search scope (Optional).

Parameters:
  `partitionName` - partition name
Returns:
  `Builder`

#### withMetricType

    public SearchParam.Builder withMetricType​(@NonNull
                                              @NonNull MetricType metricType)

Sets metric type of ANN searching.

Parameters:
  `metricType` - metric type
Returns:
  `Builder`

#### withVectorFieldName

    public SearchParam.Builder withVectorFieldName​(@NonNull
                                                   @NonNull java.lang.String vectorFieldName)

Sets target vector field by name. Field name cannot be empty or null.

Parameters:
  `vectorFieldName` - vector field name
Returns:
  `Builder`

#### withTopK

    public SearchParam.Builder withTopK​(@NonNull
                                        @NonNull java.lang.Integer topK)

Sets topK value of ANN search.

Parameters:
  `topK` - topK value
Returns:
  `Builder`

#### withExpr

    public SearchParam.Builder withExpr​(@NonNull
                                        @NonNull java.lang.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​(@NonNull
                                             @NonNull java.util.List<java.lang.String> outFields)

Specifies output fields (Optional).

Parameters:
  `outFields` - output fields
Returns:
  `Builder`

#### addOutField

    public SearchParam.Builder addOutField​(@NonNull
                                           @NonNull java.lang.String fieldName)

Specifies an output field (Optional).

Parameters:
  `fieldName` - filed name
Returns:
  `Builder`

#### withVectors

    public SearchParam.Builder withVectors​(@NonNull
                                           @NonNull java.util.List<?> vectors)

Sets the target vectors.

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;
Returns:
  `Builder`

#### withRoundDecimal

    public SearchParam.Builder withRoundDecimal​(@NonNull
                                                @NonNull java.lang.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​(@NonNull
                                          @NonNull java.lang.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​(@NonNull
                                                 @NonNull java.lang.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.TRUE` ignore, Boolean.FALSE is not
Returns:
  `Builder`

#### build

    public SearchParam build()
                      throws ParamException

Verifies parameters and creates a new `SearchParam` instance.

Returns:
  `SearchParam`
Throws:
  `ParamException`