diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5b13f073e..c635d2be3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -92,7 +92,7 @@ jobs: fail-fast: false matrix: WEAVIATE_VERSION: - ["1.32.24", "1.33.11", "1.34.7", "1.35.2", "1.36.9", "1.37.1"] + ["1.32.24", "1.33.11", "1.34.7", "1.35.2", "1.36.9", "1.37.2"] steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 diff --git a/src/it/java/io/weaviate/containers/Weaviate.java b/src/it/java/io/weaviate/containers/Weaviate.java index d7c7fcd03..33eda3402 100644 --- a/src/it/java/io/weaviate/containers/Weaviate.java +++ b/src/it/java/io/weaviate/containers/Weaviate.java @@ -45,7 +45,7 @@ public enum Version { V134(1, 34, 7), V135(1, 35, 2), V136(1, 36, 9), - V137(1, 37, 1); + V137(1, 37, 2); public final SemanticVersion semver; diff --git a/src/it/java/io/weaviate/integration/CollectionsITest.java b/src/it/java/io/weaviate/integration/CollectionsITest.java index 889041277..927b2ac05 100644 --- a/src/it/java/io/weaviate/integration/CollectionsITest.java +++ b/src/it/java/io/weaviate/integration/CollectionsITest.java @@ -18,6 +18,8 @@ import io.weaviate.client6.v1.api.collections.Quantization; import io.weaviate.client6.v1.api.collections.ReferenceProperty; import io.weaviate.client6.v1.api.collections.Replication; +import io.weaviate.client6.v1.api.collections.TextAnalyzer; +import io.weaviate.client6.v1.api.collections.Tokenization; import io.weaviate.client6.v1.api.collections.Replication.AsyncReplicationConfig; import io.weaviate.client6.v1.api.collections.VectorConfig; import io.weaviate.client6.v1.api.collections.VectorIndex; @@ -399,6 +401,67 @@ public void test_dropVectorIndex() throws IOException { .matches(VectorIndex::isNone).as("is 'none'"); } + @Test + public void testTextAnalyzer() throws Exception { + Weaviate.Version.V137.orSkip(); + + var nsTextAnalyzer = ns("TextAnalyzer"); + var textAnalyzer = client.collections.create(nsTextAnalyzer, c -> c + .properties( + Property.text("text_default", + p -> p.tokenization(Tokenization.WORD)), + Property.text("text_folded", + p -> p.tokenization(Tokenization.WORD) + .textAnalyzer(TextAnalyzer.of(t -> t.foldAscii(true)))), + Property.text("text_folded_keep_e", + p -> p.tokenization(Tokenization.WORD) + .textAnalyzer(TextAnalyzer.of(t -> t + .foldAscii(true) + .keepAscii("é")))), + Property.text("name_en", + p -> p.tokenization(Tokenization.WORD) + .textAnalyzer(TextAnalyzer.of(t -> t.stopwordPreset("en")))), + Property.text("name_none", + p -> p.tokenization(Tokenization.WORD) + .textAnalyzer(TextAnalyzer.of(t -> t.stopwordPreset("none")))))); + + Assertions.assertThat(textAnalyzer.config.get()) + .get() + .extracting(CollectionConfig::properties, InstanceOfAssertFactories.list(Property.class)) + .allSatisfy(property -> { + var analyzer = property.textAnalyzer(); + switch (property.propertyName()) { + case "text_default": + Assertions.assertThat(analyzer) + .as("default property has no textAnalyzer config") + .isNull(); + break; + case "text_folded": + Assertions.assertThat(analyzer) + .as("text_folded persists asciiFold=true") + .returns(true, TextAnalyzer::foldAscii); + break; + case "text_folded_keep_e": + Assertions.assertThat(analyzer) + .as("text_folded_keep_e persists asciiFold=true and asciiFoldIgnore=[é]") + .returns(true, TextAnalyzer::foldAscii) + .extracting(TextAnalyzer::keepAscii, InstanceOfAssertFactories.list(String.class)) + .containsExactly("é"); + break; + case "name_en": + Assertions.assertThat(analyzer) + .as("name_en persists stopwordPreset=en") + .returns("en", TextAnalyzer::stopwordPreset); + break; + case "name_none": + Assertions.assertThat(analyzer) + .as("name_none persists stopwordPreset=none") + .returns("none", TextAnalyzer::stopwordPreset); + break; + } + }); + } + @Test public void test_asyncReplicationConfig() throws IOException { Weaviate.Version.latest().orSkip(); diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/TextAnalyzer.java b/src/main/java/io/weaviate/client6/v1/api/collections/TextAnalyzer.java index 3265b63a5..045e85d4c 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/TextAnalyzer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/TextAnalyzer.java @@ -10,9 +10,9 @@ import io.weaviate.client6.v1.internal.ObjectBuilder; public record TextAnalyzer( - @SerializedName("ascii_fold") Boolean foldAscii, - @SerializedName("ascii_fold_ignore") List keepAscii, - @SerializedName("stopword_preset") String stopwordPreset) { + @SerializedName("asciiFold") Boolean foldAscii, + @SerializedName("asciiFoldIgnore") List keepAscii, + @SerializedName("stopwordPreset") String stopwordPreset) { public static TextAnalyzer of() { return null;