public final class VectorQuery<K,V> extends Query<javax.cache.Cache.Entry<K,V>>
QueryVectorField
and be of type float[]
.
'Person'
class defined as follows:
public class Person { private long id; private String name; // Index for vector search. @QueryVectorField private float[] resume; ... }Here is a possible query that will use Lucene vector search to scan all resumes to check if employees have
Master
degree:
Query<Cache.Entry<Long, Person>> qry =
new VectorQuery(Person.class, "resume", toEmbedding("Master"), 1);
// Query all cache nodes.
cache.query(qry).getAll();
Where toEmbedding
is a function that converts text to vector with the transformer
and 1 is the number of vectors to return.
IgniteCache.query(Query)
,
Serialized FormDFLT_PAGE_SIZE
Constructor and Description |
---|
VectorQuery(Class<?> type,
String field,
float[] clauseVector,
int k)
Constructs query for the given search vector.
|
VectorQuery(Class<?> type,
String field,
float[] clauseVector,
int k,
float threshold)
Constructs query for the given search vector.
|
VectorQuery(String type,
String field,
float[] clauseVector,
int k)
Constructs query for the given search string.
|
VectorQuery(String type,
String field,
float[] clauseVector,
int k,
float threshold)
Constructs query for the given search string.
|
Modifier and Type | Method and Description |
---|---|
float[] |
getClauseVector()
Gets search vector.
|
String |
getField()
Gets field for query.
|
int |
getK()
Gets k (the number of vectors to return).
|
float |
getThreshold()
Gets k (the number of vectors to return).
|
String |
getType()
Gets type for query.
|
VectorQuery<K,V> |
setClauseVector(float[] clauseVector)
Sets text search vector.
|
VectorQuery<K,V> |
setField(String field)
Sets field for query.
|
VectorQuery<K,V> |
setK(int k)
Sets k (the number of vectors to return).
|
VectorQuery<K,V> |
setLocal(boolean loc)
Sets whether this query should be executed on local node only.
|
VectorQuery<K,V> |
setPageSize(int pageSize)
Sets optional page size, if
0 , then default is used. |
VectorQuery<K,V> |
setThreshold(float threshold)
Sets k (the number of vectors to return).
|
VectorQuery<K,V> |
setType(Class<?> type)
Sets type for query.
|
VectorQuery<K,V> |
setType(String type)
Sets type for query.
|
String |
toString() |
getPageSize, isLocal, prepare
public VectorQuery(Class<?> type, String field, float[] clauseVector, int k)
type
- Type.field
- Type.clauseVector
- Search vector.k
- The number of vectors to return.public VectorQuery(Class<?> type, String field, float[] clauseVector, int k, float threshold)
type
- Type.field
- Type.clauseVector
- Search vector.k
- The number of vectors to return.threshold
- The threshold for similarity.public VectorQuery(String type, String field, float[] clauseVector, int k)
type
- Type.field
- Type.clauseVector
- Search string.k
- The number of vectors to return.public String getType()
public VectorQuery<K,V> setType(String type)
type
- Type.this
For chaining.public VectorQuery<K,V> setType(Class<?> type)
type
- Type.this
For chaining.public VectorQuery<K,V> setK(int k)
k
- K.this
For chaining.public int getK()
public VectorQuery<K,V> setThreshold(float threshold)
threshold
- threshold.this
For chaining.public float getThreshold()
public String getField()
public VectorQuery<K,V> setField(String field)
field
- field.this
For chaining.public float[] getClauseVector()
public VectorQuery<K,V> setClauseVector(float[] clauseVector)
clauseVector
- Text search string as vector.this
For chaining.public VectorQuery<K,V> setPageSize(int pageSize)
0
, then default is used.setPageSize
in class Query<javax.cache.Cache.Entry<K,V>>
pageSize
- Optional page size.this
for chaining.public VectorQuery<K,V> setLocal(boolean loc)
GridGain In-Memory Computing Platform : ver. 8.9.17 Release Date : January 24 2025