Package com.redis.vl.query
Class VectorQuery
java.lang.Object
com.redis.vl.query.VectorQuery
Represents a vector similarity search query
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic VectorQuery.Builder
builder()
Create a builderGet the batch sizeGet the distance metricGet the EF runtime parameter for HNSWgetField()
Get the vector field nameGet the filter queryGet the hybrid search fieldGet the hybrid search policyGet the hybrid search queryint
getK()
Deprecated.Use getNumResults() insteadint
Get the number of results to returnGet the pre-filter expressionGet the fields to return in resultsGet the sort fieldfloat[]
Get the query vectorboolean
Check if terms must be in orderboolean
Check if vector distance should be normalizedboolean
Check if distance values should be returnedboolean
Check if similarity scores should be returnedboolean
Check if sorting is descendingstatic VectorQuery.Builder
Create a VectorQuery with fluent API for double arraystatic VectorQuery.Builder
Create a VectorQuery with fluent API for float arrayvoid
setBatchSize
(int batchSize) Set the batch sizevoid
setEfRuntime
(int efRuntime) Set the EF runtime parameter for HNSWvoid
Set the filter queryvoid
setHybridPolicy
(String policy) Set the hybrid search policytoParams()
Convert to parameter map for query executionBuild the query string for RedistoString()
Create a copy with modified distance metricwithK
(int newK) Deprecated.Use withNumResults() insteadwithNumResults
(int newNumResults) Create a copy with modified numResults valuewithPreFilter
(String filter) Create a copy with modified pre-filter
-
Method Details
-
builder
Create a builder- Returns:
- Vector query builder
-
of
Create a VectorQuery with fluent API for float array- Parameters:
field
- Vector field namevector
- Query vector- Returns:
- Vector query builder
-
of
Create a VectorQuery with fluent API for double array- Parameters:
field
- Vector field namevector
- Query vector- Returns:
- Vector query builder
-
withNumResults
Create a copy with modified numResults value- Parameters:
newNumResults
- New number of results to return- Returns:
- New VectorQuery instance
-
withK
Deprecated.Use withNumResults() insteadCreate a copy with modified K value- Parameters:
newK
- New K value- Returns:
- New VectorQuery instance
-
withDistanceMetric
Create a copy with modified distance metric- Parameters:
metric
- New distance metric- Returns:
- New VectorQuery instance
-
withPreFilter
Create a copy with modified pre-filter- Parameters:
filter
- New pre-filter expression- Returns:
- New VectorQuery instance
-
toQueryString
Build the query string for Redis- Returns:
- Query string
-
toParams
Convert to parameter map for query execution- Returns:
- Parameters map
-
getField
Get the vector field name- Returns:
- Field name
-
getVector
public float[] getVector()Get the query vector- Returns:
- Query vector as float array
-
getNumResults
public int getNumResults()Get the number of results to return- Returns:
- Number of results
-
getK
Deprecated.Use getNumResults() insteadGet the K value (number of results)- Returns:
- Number of results
-
getDistanceMetric
Get the distance metric- Returns:
- Distance metric
-
isReturnDistance
public boolean isReturnDistance()Check if distance values should be returned- Returns:
- True if distance values should be returned
-
isReturnScore
public boolean isReturnScore()Check if similarity scores should be returned- Returns:
- True if scores should be returned
-
getPreFilter
Get the pre-filter expression- Returns:
- Pre-filter expression
-
getHybridField
Get the hybrid search field- Returns:
- Hybrid field name
-
getHybridQuery
Get the hybrid search query- Returns:
- Hybrid query string
-
getEfRuntime
Get the EF runtime parameter for HNSW- Returns:
- EF runtime value
-
setEfRuntime
public void setEfRuntime(int efRuntime) Set the EF runtime parameter for HNSW- Parameters:
efRuntime
- EF runtime value
-
getReturnFields
Get the fields to return in results- Returns:
- List of field names
-
getFilter
Get the filter query- Returns:
- Filter instance
-
setFilter
Set the filter query- Parameters:
filter
- Filter instance
-
getHybridPolicy
Get the hybrid search policy- Returns:
- Hybrid policy
-
setHybridPolicy
Set the hybrid search policy- Parameters:
policy
- Hybrid policy
-
getBatchSize
Get the batch size- Returns:
- Batch size
-
setBatchSize
public void setBatchSize(int batchSize) Set the batch size- Parameters:
batchSize
- Batch size
-
isNormalizeVectorDistance
public boolean isNormalizeVectorDistance()Check if vector distance should be normalized- Returns:
- True if normalization is enabled
-
getSortBy
Get the sort field- Returns:
- Sort field name
-
isSortDescending
public boolean isSortDescending()Check if sorting is descending- Returns:
- True if descending
-
isInOrder
public boolean isInOrder()Check if terms must be in order- Returns:
- True if in-order is required
-
toString
-