Skip to content

Commit bbb4377

Browse files
committed
chore: remove deprecated vectorizer parameter
1 parent 73dfa06 commit bbb4377

File tree

4 files changed

+24
-32
lines changed

4 files changed

+24
-32
lines changed

src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecClipVectorizer.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import io.weaviate.client6.v1.internal.ObjectBuilder;
1414

1515
public record Multi2VecClipVectorizer(
16-
@SerializedName("vectorizeClassName") boolean vectorizeCollectionName,
1716
@SerializedName("inferenceUrl") String inferenceUrl,
1817
@SerializedName("imageFields") List<String> imageFields,
1918
@SerializedName("textFields") List<String> textFields,
@@ -45,7 +44,6 @@ public static Multi2VecClipVectorizer of(Function<Builder, ObjectBuilder<Multi2V
4544

4645
public Multi2VecClipVectorizer(Builder builder) {
4746
this(
48-
builder.vectorizeCollectionName,
4947
builder.inferenceUrl,
5048
builder.imageFields.keySet().stream().toList(),
5149
builder.textFields.keySet().stream().toList(),
@@ -57,7 +55,6 @@ public Multi2VecClipVectorizer(Builder builder) {
5755

5856
public static class Builder implements ObjectBuilder<Multi2VecClipVectorizer> {
5957
private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX;
60-
private boolean vectorizeCollectionName = false;
6158
private String inferenceUrl;
6259
private Map<String, Float> imageFields = new HashMap<>();
6360
private Map<String, Float> textFields = new HashMap<>();
@@ -95,11 +92,6 @@ public Builder textField(String field, float weight) {
9592
return this;
9693
}
9794

98-
public Builder vectorizeCollectionName(boolean enable) {
99-
this.vectorizeCollectionName = enable;
100-
return this;
101-
}
102-
10395
public Builder vectorIndex(VectorIndex vectorIndex) {
10496
this.vectorIndex = vectorIndex;
10597
return this;

src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecContextionaryVectorizer.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
import io.weaviate.client6.v1.internal.ObjectBuilder;
1010

1111
public record Text2VecContextionaryVectorizer(
12-
@SerializedName("vectorizeClassName") boolean vectorizeCollectionName,
12+
/**
13+
* Weaviate defaults to {@code true} if the value is not provided.
14+
* Because text2vec-contextionary cannot handle understores in collection names,
15+
* this quickly becomes inconvenient.
16+
*
17+
* To avoid that we send "vectorizeClassName": false all the time
18+
* and make it impossible to enable this feature, as it is deprecated.
19+
*/
20+
@Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName,
1321
VectorIndex vectorIndex) implements Vectorizer {
1422

1523
@Override
@@ -31,18 +39,22 @@ public static Text2VecContextionaryVectorizer of(
3139
return fn.apply(new Builder()).build();
3240
}
3341

42+
/**
43+
* Canonical constructor always sets {@link #vectorizeCollectionName} to false.
44+
*/
45+
public Text2VecContextionaryVectorizer(boolean vectorizeCollectionName, VectorIndex vectorIndex) {
46+
this.vectorizeCollectionName = false;
47+
this.vectorIndex = vectorIndex;
48+
}
49+
3450
public Text2VecContextionaryVectorizer(Builder builder) {
3551
this(builder.vectorizeCollectionName, builder.vectorIndex);
3652
}
3753

3854
public static class Builder implements ObjectBuilder<Text2VecContextionaryVectorizer> {
39-
private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX;
40-
private boolean vectorizeCollectionName = false;
55+
private final boolean vectorizeCollectionName = false;
4156

42-
public Builder vectorizeCollectionName(boolean enable) {
43-
this.vectorizeCollectionName = enable;
44-
return this;
45-
}
57+
private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX;
4658

4759
public Builder vectorIndex(VectorIndex vectorIndex) {
4860
this.vectorIndex = vectorIndex;

src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecWeaviateVectorizer.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import io.weaviate.client6.v1.internal.ObjectBuilder;
1010

1111
public record Text2VecWeaviateVectorizer(
12-
@SerializedName("vectorizeClassName") boolean vectorizeCollectionName,
1312
@SerializedName("baseUrl") String inferenceUrl,
1413
@SerializedName("dimensions") Integer dimensions,
1514
@SerializedName("model") String model,
@@ -34,7 +33,7 @@ public static Text2VecWeaviateVectorizer of(Function<Builder, ObjectBuilder<Text
3433
}
3534

3635
public Text2VecWeaviateVectorizer(Builder builder) {
37-
this(builder.vectorizeCollectionName,
36+
this(
3837
builder.inferenceUrl,
3938
builder.dimensions,
4039
builder.model,
@@ -46,16 +45,10 @@ public Text2VecWeaviateVectorizer(Builder builder) {
4645

4746
public static class Builder implements ObjectBuilder<Text2VecWeaviateVectorizer> {
4847
private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX;
49-
private boolean vectorizeCollectionName = false;
5048
private String inferenceUrl;
5149
private Integer dimensions;
5250
private String model;
5351

54-
public Builder vectorizeCollectionName(boolean enable) {
55-
this.vectorizeCollectionName = enable;
56-
return this;
57-
}
58-
5952
public Builder inferenceUrl(String inferenceUrl) {
6053
this.inferenceUrl = inferenceUrl;
6154
return this;

src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,14 @@ public static Object[][] testCases() {
7373
Multi2VecClipVectorizer.of(m2v -> m2v
7474
.inferenceUrl("http://example.com")
7575
.imageField("img", 1f)
76-
.textField("txt", 2f)
77-
.vectorizeCollectionName(true)),
76+
.textField("txt", 2f)),
7877
"""
7978
{
8079
"vectorIndexType": "hnsw",
8180
"vectorIndexConfig": {},
8281
"vectorizer": {
8382
"multi2vec-clip": {
8483
"inferenceUrl": "http://example.com",
85-
"vectorizeClassName": true,
8684
"imageFields": ["img"],
8785
"textFields": ["txt"],
8886
"weights": {
@@ -96,15 +94,14 @@ public static Object[][] testCases() {
9694
},
9795
{
9896
Vectorizer.class,
99-
Text2VecContextionaryVectorizer.of(t2v -> t2v
100-
.vectorizeCollectionName(true)),
97+
Text2VecContextionaryVectorizer.of(),
10198
"""
10299
{
103100
"vectorIndexType": "hnsw",
104101
"vectorIndexConfig": {},
105102
"vectorizer": {
106103
"text2vec-contextionary": {
107-
"vectorizeClassName": true
104+
"vectorizeClassName": false
108105
}
109106
}
110107
}
@@ -115,16 +112,14 @@ public static Object[][] testCases() {
115112
Text2VecWeaviateVectorizer.of(t2v -> t2v
116113
.inferenceUrl("http://example.com")
117114
.dimensions(4)
118-
.model("very-good-model")
119-
.vectorizeCollectionName(true)),
115+
.model("very-good-model")),
120116
"""
121117
{
122118
"vectorIndexType": "hnsw",
123119
"vectorIndexConfig": {},
124120
"vectorizer": {
125121
"text2vec-weaviate": {
126122
"baseUrl": "http://example.com",
127-
"vectorizeClassName": true,
128123
"dimensions": 4,
129124
"model": "very-good-model"
130125
}

0 commit comments

Comments
 (0)