diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java b/src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java index df3064d6c..6535c1d6c 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java @@ -15,6 +15,7 @@ import io.weaviate.client6.v1.api.collections.vectorindex.Dynamic; import io.weaviate.client6.v1.api.collections.vectorindex.Flat; +import io.weaviate.client6.v1.api.collections.vectorindex.HFresh; import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw; import io.weaviate.client6.v1.internal.TaggedUnion; import io.weaviate.client6.v1.internal.json.JsonEnum; @@ -26,7 +27,8 @@ public interface VectorIndex extends TaggedUnion { enum Kind implements JsonEnum { HNSW("hnsw"), FLAT("flat"), - DYNAMIC("dynamic"); + DYNAMIC("dynamic"), + HFRESH("hfresh"); private static final Map jsonValueMap = JsonEnum.collectNames(Kind.values()); private final String jsonValue; @@ -75,6 +77,16 @@ default Dynamic asDynamic() { return _as(VectorIndex.Kind.DYNAMIC); } + /** Is this vector index of type HFRESH? */ + default boolean isHFresh() { + return _is(VectorIndex.Kind.HFRESH); + } + + /** Get as {@link HFresh} instance. */ + default HFresh asHFresh() { + return _as(VectorIndex.Kind.HFRESH); + } + static enum CustomTypeAdapterFactory implements TypeAdapterFactory { INSTANCE; @@ -89,6 +101,7 @@ private final void init(Gson gson) { addAdapter(gson, VectorIndex.Kind.HNSW, Hnsw.class); addAdapter(gson, VectorIndex.Kind.FLAT, Flat.class); addAdapter(gson, VectorIndex.Kind.DYNAMIC, Dynamic.class); + addAdapter(gson, VectorIndex.Kind.HFRESH, HFresh.class); } @SuppressWarnings("unchecked") diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/HFresh.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/HFresh.java new file mode 100644 index 000000000..83eaf94f9 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/HFresh.java @@ -0,0 +1,73 @@ +package io.weaviate.client6.v1.api.collections.vectorindex; + +import java.util.function.Function; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record HFresh( + @SerializedName("distance") Distance distance, + @SerializedName("maxPostingSizeKB") Integer maxPostingSizeKb, + @SerializedName("replicas") Integer replicaCount, + @SerializedName("searchProbe") Integer searchProbe) implements VectorIndex { + + @Override + public VectorIndex.Kind _kind() { + return VectorIndex.Kind.HFRESH; + } + + @Override + public Object _self() { + return this; + } + + public static HFresh of() { + return of(ObjectBuilder.identity()); + } + + public static HFresh of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public HFresh(Builder builder) { + this( + builder.distance, + builder.maxPostingSizeKb, + builder.replicaCount, + builder.searchProbe); + } + + public static class Builder implements ObjectBuilder { + private Distance distance; + private Integer maxPostingSizeKb; + private Integer replicaCount; + private Integer searchProbe; + + public Builder distance(Distance distance) { + this.distance = distance; + return this; + } + + public final Builder maxPostingSizeKb(int maxPostingSizeKb) { + this.maxPostingSizeKb = maxPostingSizeKb; + return this; + } + + public final Builder replicaCount(int replicaCount) { + this.replicaCount = replicaCount; + return this; + } + + public final Builder searchProbe(int searchProbe) { + this.searchProbe = searchProbe; + return this; + } + + @Override + public HFresh build() { + return new HFresh(this); + } + } +} diff --git a/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java b/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java index 7dee98b08..8a60831be 100644 --- a/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java +++ b/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java @@ -1,26 +1,5 @@ package io.weaviate.client6.v1.internal.json; -import io.weaviate.client6.v1.api.collections.vectorizers.Multi2MultiVecJinaAiVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecAwsVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecCohereVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecGoogleVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecJinaAiVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecNvidiaVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecVoyageAiVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecAwsVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecAzureOpenAiVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecDatabricksVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecGoogleVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecHuggingFaceVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecJinaAiVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecMistralVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecModel2VecVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecMorphVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecNvidiaVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecOllamaVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecOpenAiVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecTransformersVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecVoyageAiVectorizer; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -55,13 +34,34 @@ import io.weaviate.client6.v1.api.collections.vectorindex.Distance; import io.weaviate.client6.v1.api.collections.vectorindex.Dynamic; import io.weaviate.client6.v1.api.collections.vectorindex.Flat; +import io.weaviate.client6.v1.api.collections.vectorindex.HFresh; import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw; import io.weaviate.client6.v1.api.collections.vectorindex.MultiVector; import io.weaviate.client6.v1.api.collections.vectorindex.MultiVector.Aggregation; import io.weaviate.client6.v1.api.collections.vectorizers.Img2VecNeuralVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2MultiVecJinaAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecAwsVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecClipVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecCohereVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecGoogleVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecJinaAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecNvidiaVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecVoyageAiVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.SelfProvidedVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecAwsVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecCohereVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecDatabricksVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecGoogleVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecHuggingFaceVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecJinaAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecMistralVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecModel2VecVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecMorphVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecNvidiaVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecOllamaVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecOpenAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecTransformersVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecVoyageAiVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecWeaviateVectorizer; import io.weaviate.client6.v1.api.rbac.AliasesPermission; import io.weaviate.client6.v1.api.rbac.BackupsPermission; @@ -150,564 +150,728 @@ public static Object[][] testCases() { """, }, { - VectorConfig.class, - Text2VecCohereVectorizer.of( - v -> v.sourceProperties("a").model("embed-v4.0") - ), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-cohere": { - "model": "embed-v4.0", - "vectorizeClassName": false, - "properties": ["a"] + VectorConfig.class, + Text2VecCohereVectorizer.of( + v -> v.sourceProperties("a").model("embed-v4.0")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-cohere": { + "model": "embed-v4.0", + "vectorizeClassName": false, + "properties": ["a"] + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecAwsVectorizer.bedrock("amazon.titan-embed-text-v2:0"), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-aws": { - "service": "bedrock", - "model": "amazon.titan-embed-text-v2:0", - "vectorizeClassName": false + VectorConfig.class, + Text2VecAwsVectorizer.bedrock("amazon.titan-embed-text-v2:0"), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-aws": { + "service": "bedrock", + "model": "amazon.titan-embed-text-v2:0", + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecDatabricksVectorizer.of(), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-databricks": { - "vectorizeClassName": false + VectorConfig.class, + Text2VecDatabricksVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-databricks": { + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecDatabricksVectorizer.of(v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-databricks": { - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecDatabricksVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-databricks": { + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecGoogleVectorizer.vertex("projectId", v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-google": { - "apiEndpoint":"us-central1-aiplatform.googleapis.com", - "projectId": "projectId", - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecGoogleVectorizer.vertex("projectId", v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-google": { + "apiEndpoint":"us-central1-aiplatform.googleapis.com", + "projectId": "projectId", + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecGoogleVectorizer.aiStudio(v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-google": { - "apiEndpoint":"generativelanguage.googleapis.com", - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecGoogleVectorizer.aiStudio(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-google": { + "apiEndpoint":"generativelanguage.googleapis.com", + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecHuggingFaceVectorizer.of(), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-huggingface": { - "vectorizeClassName": false + VectorConfig.class, + Text2VecHuggingFaceVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-huggingface": { + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecHuggingFaceVectorizer.of(v -> v.sourceProperties("a").model("model")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-huggingface": { - "model": "model", - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecHuggingFaceVectorizer.of(v -> v.sourceProperties("a").model("model")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-huggingface": { + "model": "model", + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecJinaAiVectorizer.of(), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-jinaai": { - "vectorizeClassName": false + VectorConfig.class, + Text2VecJinaAiVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-jinaai": { + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecJinaAiVectorizer.of(v -> v.sourceProperties("a").model(Text2VecJinaAiVectorizer.JINA_EMBEDDINGS_V2_BASE_EN)), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-jinaai": { - "model": "jina-embeddings-v2-base-en", - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecJinaAiVectorizer + .of(v -> v.sourceProperties("a").model(Text2VecJinaAiVectorizer.JINA_EMBEDDINGS_V2_BASE_EN)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-jinaai": { + "model": "jina-embeddings-v2-base-en", + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecMistralVectorizer.of(), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-mistral": { - "vectorizeClassName": false + VectorConfig.class, + Text2VecMistralVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-mistral": { + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecMistralVectorizer.of(v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-mistral": { - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecMistralVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-mistral": { + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecModel2VecVectorizer.of(), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-model2vec": { - "vectorizeClassName": false + VectorConfig.class, + Text2VecModel2VecVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-model2vec": { + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecModel2VecVectorizer.of(v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-model2vec": { - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecModel2VecVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-model2vec": { + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecMorphVectorizer.of(), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-morph": {} + VectorConfig.class, + Text2VecMorphVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-morph": {} + } } - } - """, + """, }, { - VectorConfig.class, - Text2VecMorphVectorizer.of(v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-morph": { - "properties": ["a"] + VectorConfig.class, + Text2VecMorphVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-morph": { + "properties": ["a"] + } } } - } - """, + """, + }, + { + VectorConfig.class, + Text2VecNvidiaVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-nvidia": { + "vectorizeClassName": false + } + } + } + """, }, { - VectorConfig.class, - Text2VecNvidiaVectorizer.of(), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-nvidia": { - "vectorizeClassName": false + VectorConfig.class, + Text2VecNvidiaVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-nvidia": { + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecNvidiaVectorizer.of(v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-nvidia": { - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecOllamaVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-ollama": { + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecOllamaVectorizer.of(), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-ollama": { - "vectorizeClassName": false + VectorConfig.class, + Text2VecOllamaVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-ollama": { + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecOllamaVectorizer.of(v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-ollama": { - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Text2VecOpenAiVectorizer + .of(v -> v.sourceProperties("a").model(Text2VecOpenAiVectorizer.TEXT_EMBEDDING_3_LARGE)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-openai": { + "model": "text-embedding-3-large", + "properties": ["a"], + "vectorizeClassName": false + } } } - } - """, + """, + }, + { + VectorConfig.class, + Text2VecTransformersVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-transformers": {} + } + } + """, + }, + { + VectorConfig.class, + Text2VecVoyageAiVectorizer + .of(v -> v.sourceProperties("a").model(Text2VecVoyageAiVectorizer.VOYAGE_3_LARGE)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-voyageai": { + "model": "voyage-3-large", + "properties": ["a"], + "vectorizeClassName":false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecTransformersVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-transformers": { + "properties": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecWeaviateVectorizer.of(t2v -> t2v + .baseUrl("http://example.com") + .dimensions(4) + .model("very-good-model")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-weaviate": { + "baseURL": "http://example.com", + "dimensions": 4, + "model": "very-good-model" + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecOpenAiVectorizer.of(v -> v.sourceProperties("a", "b")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-openai": { + "vectorizeClassName": false, + "properties": ["a", "b"] + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecVoyageAiVectorizer.of(v -> v.sourceProperties(List.of("a", "b", "c")).model("voyage-3-large")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-voyageai": { + "model": "voyage-3-large", + "vectorizeClassName": false, + "properties": ["a", "b", "c"] + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecVoyageAiVectorizer.of(v -> v.dimensions(256).model("voyage-3-large")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-voyageai": { + "model": "voyage-3-large", + "dimensions": 256, + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Img2VecNeuralVectorizer.of(v -> v.imageFields("a", "b")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "img2vec-neural": { + "imageFields": ["a", "b"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2MultiVecJinaAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2multivec-jinaai": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, }, { - VectorConfig.class, - Text2VecOpenAiVectorizer.of(v -> v.sourceProperties("a").model(Text2VecOpenAiVectorizer.TEXT_EMBEDDING_3_LARGE)), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-openai": { - "model": "text-embedding-3-large", - "properties": ["a"], - "vectorizeClassName": false + VectorConfig.class, + Multi2VecClipVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-clip": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecClipVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-clip": { + "imageFields": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecClipVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-clip": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } } } - } - """, + """, }, { - VectorConfig.class, - Text2VecTransformersVectorizer.of(), - """ + VectorConfig.class, + Multi2VecAwsVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ { "vectorIndexType": "hnsw", "vectorIndexConfig": {}, "vectorizer": { - "text2vec-transformers": {} + "multi2vec-aws": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } } } """, }, { - VectorConfig.class, - Text2VecVoyageAiVectorizer.of(v -> v.sourceProperties("a").model(Text2VecVoyageAiVectorizer.VOYAGE_3_LARGE)), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-voyageai": { - "model": "voyage-3-large", - "properties": ["a"], - "vectorizeClassName":false - } - } - } - """, - }, - { - VectorConfig.class, - Text2VecTransformersVectorizer.of(v -> v.sourceProperties("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-transformers": { - "properties": ["a"] + VectorConfig.class, + Multi2VecAwsVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-aws": { + "imageFields": ["a"] + } } } - } - """, + """, }, { VectorConfig.class, - Text2VecWeaviateVectorizer.of(t2v -> t2v - .baseUrl("http://example.com") - .dimensions(4) - .model("very-good-model")), + Multi2VecAwsVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), """ { "vectorIndexType": "hnsw", "vectorIndexConfig": {}, "vectorizer": { - "text2vec-weaviate": { - "baseURL": "http://example.com", - "dimensions": 4, - "model": "very-good-model" + "multi2vec-aws": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } } } } """, }, { - VectorConfig.class, - Text2VecOpenAiVectorizer.of(v -> v.sourceProperties("a", "b")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-openai": { - "vectorizeClassName": false, - "properties": ["a", "b"] - } + VectorConfig.class, + Multi2VecCohereVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-cohere": { + "imageFields": ["a", "b"], + "textFields": ["c"] } } - """, + } + """, }, { - VectorConfig.class, - Text2VecVoyageAiVectorizer.of(v -> - v.sourceProperties(List.of("a", "b", "c")).model("voyage-3-large")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-voyageai": { - "model": "voyage-3-large", - "vectorizeClassName": false, - "properties": ["a", "b", "c"] - } - } + VectorConfig.class, + Multi2VecCohereVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-cohere": { + "imageFields": ["a"] } - """, - }, - { - VectorConfig.class, - Text2VecVoyageAiVectorizer.of(v -> - v.dimensions(256).model("voyage-3-large")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "text2vec-voyageai": { - "model": "voyage-3-large", - "dimensions": 256, - "vectorizeClassName": false - } - } - } - """, - }, - { - VectorConfig.class, - Img2VecNeuralVectorizer.of(v -> v.imageFields("a", "b")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "img2vec-neural": { - "imageFields": ["a", "b"] } } - } - """, + """, }, { - VectorConfig.class, - Multi2MultiVecJinaAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2multivec-jinaai": { - "imageFields": ["a", "b"], - "textFields": ["c"] + VectorConfig.class, + Multi2VecCohereVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-cohere": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } } } - } - """, + """, }, { - VectorConfig.class, - Multi2VecClipVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-clip": { - "imageFields": ["a", "b"], - "textFields": ["c"] + VectorConfig.class, + Multi2VecGoogleVectorizer.of("project-id", "location", + v -> v.imageFields("a", "b").textFields("c").videoFields("d")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-google": { + "projectId": "project-id", + "location": "location", + "imageFields": ["a", "b"], + "textFields": ["c"], + "videoFields": ["d"] + } } } - } - """, + """, }, { - VectorConfig.class, - Multi2VecClipVectorizer.of(v -> v.imageFields("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-clip": { - "imageFields": ["a"] + VectorConfig.class, + Multi2VecGoogleVectorizer.of("project-id", "location", v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-google": { + "projectId": "project-id", + "location": "location", + "imageFields": ["a"] + } } } - } - """, + """, }, { - VectorConfig.class, - Multi2VecClipVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-clip": { - "imageFields": ["a", "b"], - "textFields": ["c"], - "weights":{ - "imageWeights":[0.1,0.1], - "textWeights":[0.8] - } + VectorConfig.class, + Multi2VecGoogleVectorizer.of("project-id", "location", + v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f).videoField("d", 0.99f)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-google": { + "projectId": "project-id", + "location": "location", + "imageFields": ["a", "b"], + "textFields": ["c"], + "videoFields": ["d"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8], + "videoWeights":[0.99] + } + } } } - } - """, + """, }, { - VectorConfig.class, - Multi2VecAwsVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-aws": { - "imageFields": ["a", "b"], - "textFields": ["c"] + VectorConfig.class, + Multi2VecJinaAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-jinaai": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } } } - } - """, + """, }, { - VectorConfig.class, - Multi2VecAwsVectorizer.of(v -> v.imageFields("a")), - """ + VectorConfig.class, + Multi2VecJinaAiVectorizer.of(v -> v.imageFields("a")), + """ { "vectorIndexType": "hnsw", "vectorIndexConfig": {}, "vectorizer": { - "multi2vec-aws": { + "multi2vec-jinaai": { "imageFields": ["a"] } } @@ -715,14 +879,14 @@ public static Object[][] testCases() { """, }, { - VectorConfig.class, - Multi2VecAwsVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), - """ + VectorConfig.class, + Multi2VecJinaAiVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), + """ { "vectorIndexType": "hnsw", "vectorIndexConfig": {}, "vectorizer": { - "multi2vec-aws": { + "multi2vec-jinaai": { "imageFields": ["a", "b"], "textFields": ["c"], "weights":{ @@ -735,276 +899,106 @@ public static Object[][] testCases() { """, }, { - VectorConfig.class, - Multi2VecCohereVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-cohere": { - "imageFields": ["a", "b"], - "textFields": ["c"] - } - } - } - """, - }, - { - VectorConfig.class, - Multi2VecCohereVectorizer.of(v -> v.imageFields("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-cohere": { - "imageFields": ["a"] - } - } - } - """, - }, - { - VectorConfig.class, - Multi2VecCohereVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-cohere": { - "imageFields": ["a", "b"], - "textFields": ["c"], - "weights":{ - "imageWeights":[0.1,0.1], - "textWeights":[0.8] - } - } - } - } - """, - }, - { - VectorConfig.class, - Multi2VecGoogleVectorizer.of("project-id", "location", v -> v.imageFields("a", "b").textFields("c").videoFields("d")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-google": { - "projectId": "project-id", - "location": "location", - "imageFields": ["a", "b"], - "textFields": ["c"], - "videoFields": ["d"] - } - } - } - """, - }, - { - VectorConfig.class, - Multi2VecGoogleVectorizer.of("project-id", "location", v -> v.imageFields("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-google": { - "projectId": "project-id", - "location": "location", - "imageFields": ["a"] - } - } - } - """, - }, - { - VectorConfig.class, - Multi2VecGoogleVectorizer.of("project-id", "location",v -> - v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f).videoField("d", 0.99f) - ), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-google": { - "projectId": "project-id", - "location": "location", - "imageFields": ["a", "b"], - "textFields": ["c"], - "videoFields": ["d"], - "weights":{ - "imageWeights":[0.1,0.1], - "textWeights":[0.8], - "videoWeights":[0.99] - } - } - } - } - """, - }, - { - VectorConfig.class, - Multi2VecJinaAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-jinaai": { - "imageFields": ["a", "b"], - "textFields": ["c"] + VectorConfig.class, + Multi2VecNvidiaVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-nvidia": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } } } - } - """, + """, }, { - VectorConfig.class, - Multi2VecJinaAiVectorizer.of(v -> v.imageFields("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-jinaai": { - "imageFields": ["a"] + VectorConfig.class, + Multi2VecNvidiaVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-nvidia": { + "imageFields": ["a"] + } } } - } - """, - }, - { - VectorConfig.class, - Multi2VecJinaAiVectorizer.of(v -> - v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f) - ), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-jinaai": { - "imageFields": ["a", "b"], - "textFields": ["c"], - "weights":{ - "imageWeights":[0.1,0.1], - "textWeights":[0.8] - } - } - } - } - """, + """, }, { - VectorConfig.class, - Multi2VecNvidiaVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-nvidia": { - "imageFields": ["a", "b"], - "textFields": ["c"] + VectorConfig.class, + Multi2VecNvidiaVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-nvidia": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } } } - } - """, + """, }, { - VectorConfig.class, - Multi2VecNvidiaVectorizer.of(v -> v.imageFields("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-nvidia": { - "imageFields": ["a"] + VectorConfig.class, + Multi2VecVoyageAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-voyageai": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } } } - } - """, - }, - { - VectorConfig.class, - Multi2VecNvidiaVectorizer.of(v -> - v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f) - ), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-nvidia": { - "imageFields": ["a", "b"], - "textFields": ["c"], - "weights":{ - "imageWeights":[0.1,0.1], - "textWeights":[0.8] - } - } - } - } - """, + """, }, { - VectorConfig.class, - Multi2VecVoyageAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-voyageai": { - "imageFields": ["a", "b"], - "textFields": ["c"] + VectorConfig.class, + Multi2VecVoyageAiVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-voyageai": { + "imageFields": ["a"] + } } } - } - """, + """, }, { - VectorConfig.class, - Multi2VecVoyageAiVectorizer.of(v -> v.imageFields("a")), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-voyageai": { - "imageFields": ["a"] + VectorConfig.class, + Multi2VecVoyageAiVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-voyageai": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } } } - } - """, - }, - { - VectorConfig.class, - Multi2VecVoyageAiVectorizer.of(v -> - v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f) - ), - """ - { - "vectorIndexType": "hnsw", - "vectorIndexConfig": {}, - "vectorizer": { - "multi2vec-voyageai": { - "imageFields": ["a", "b"], - "textFields": ["c"], - "weights":{ - "imageWeights":[0.1,0.1], - "textWeights":[0.8] - } - } - } - } - """, + """, }, // VectorIndex.CustomTypeAdapterFactory @@ -1147,6 +1141,27 @@ public static Object[][] testCases() { } """, }, + { + VectorConfig.class, + SelfProvidedVectorizer.of(none -> none + .vectorIndex(HFresh.of(hfresh -> hfresh + .distance(Distance.DOT) + .maxPostingSizeKb(1) + .replicaCount(2) + .searchProbe(3)))), + """ + { + "vectorIndexType": "hfresh", + "vectorizer": {"none": {}}, + "vectorIndexConfig": { + "distance": "dot", + "maxPostingSizeKB": 1, + "replicas": 2, + "searchProbe": 3 + } + } + """, + }, { VectorConfig.class, SelfProvidedVectorizer.of(none -> none