Vector Fields
Define vector fields in GridGain with the QueryVectorField annotation and set the similarity function per field, in Java and Python.
When creating the field for a vector, mark the field that will hold the vector with the QueryVectorField annotation. This field must have the float[] type. GridGain will create a vector index based on the provided embedding.
The example below shows a class that uses a text field and a vector field:
public class Article {
/**
* Content (indexed).
*/
@QueryTextField
private String content;
@QueryVectorField
private float[] contentVector;
/**
* Required for binary deserialization.
*/
public Article() {
// No-op.
}
public Article(String content, float[] contentVector) {
this.content = content;
this.contentVector = contentVector;
}
}Objects with vector fields can be stored as normal. GridGain will build an additional index for the vector column that can be queried.
Setting the Similarity Function
You can choose which similarity function a vector field uses through the similarityFunction parameter of the QueryVectorField annotation. The example below shows a class with a vector field configured with a similarity function:
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

