Skip to content

Commit b21d8b2

Browse files
authored
Merge branch 'v6' into v6-weaviate-object
2 parents b7c2020 + 12f5388 commit b21d8b2

39 files changed

Lines changed: 277 additions & 263 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ record Artist(String firstName, String lastName, int age) {};
701701

702702
record Song(String title, Artist artist) {};
703703

704-
var song1 = songs.query.byId(
704+
var song1 = songs.query.fetchObjectById(
705705
uuid1,
706706
song -> song.returnReferences(QueryReference.single("artist"))
707707
);

src/it/java/io/weaviate/integration/DataITest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void testCreateGetDelete() throws IOException {
5252
.uuid(id)
5353
.vectors(Vectors.of(VECTOR_INDEX, vector)));
5454

55-
var object = artists.query.byId(id, query -> query
55+
var object = artists.query.fetchObjectById(id, query -> query
5656
.returnProperties("name")
5757
.returnMetadata(
5858
MetadataField.VECTOR,
@@ -99,7 +99,7 @@ public void testBlobData() throws IOException {
9999
"breed", "ragdoll",
100100
"img", ragdollPng));
101101

102-
var got = cats.query.byId(ragdoll.uuid(),
102+
var got = cats.query.fetchObjectById(ragdoll.uuid(),
103103
cat -> cat.returnProperties("img"));
104104

105105
Assertions.assertThat(got).get()
@@ -145,7 +145,7 @@ public void testReferences_AddReplaceDelete() throws IOException {
145145
Reference.object(albie));
146146

147147
// Assert
148-
var johnWithFriends = persons.query.byId(john.uuid(),
148+
var johnWithFriends = persons.query.fetchObjectById(john.uuid(),
149149
query -> query.returnReferences(
150150
QueryReference.single("hasFriend",
151151
friend -> friend.returnProperties("name"))));
@@ -165,7 +165,7 @@ public void testReferences_AddReplaceDelete() throws IOException {
165165
"hasFriend",
166166
Reference.object(barbara));
167167

168-
johnWithFriends = persons.query.byId(john.uuid(),
168+
johnWithFriends = persons.query.fetchObjectById(john.uuid(),
169169
query -> query.returnReferences(
170170
QueryReference.single("hasFriend",
171171
friend -> friend.returnProperties("name"))));
@@ -185,7 +185,7 @@ public void testReferences_AddReplaceDelete() throws IOException {
185185
Reference.object(barbara));
186186

187187
// Assert
188-
johnWithFriends = persons.query.byId(john.uuid(),
188+
johnWithFriends = persons.query.fetchObjectById(john.uuid(),
189189
query -> query.returnReferences(
190190
QueryReference.single("hasFriend")));
191191

@@ -214,7 +214,7 @@ public void testReplace() throws IOException {
214214
replace -> replace.properties(Map.of("year", 1819)));
215215

216216
// Assert
217-
var replacedIvanhoe = books.query.byId(ivanhoe.uuid());
217+
var replacedIvanhoe = books.query.fetchObjectById(ivanhoe.uuid());
218218

219219
Assertions.assertThat(replacedIvanhoe).get()
220220
.as("has ONLY year property")
@@ -258,7 +258,7 @@ public void testUpdate() throws IOException {
258258
.vectors(Vectors.of(vector)));
259259

260260
// Assert
261-
var updIvanhoe = books.query.byId(
261+
var updIvanhoe = books.query.fetchObjectById(
262262
ivanhoe.uuid(),
263263
query -> query
264264
.includeVector()
@@ -387,7 +387,7 @@ public void testReferenceAddMany() throws IOException {
387387
// Assert
388388
Assertions.assertThat(response.errors()).isEmpty();
389389

390-
var goodburgAirports = cities.query.byId(goodburg.uuid(),
390+
var goodburgAirports = cities.query.fetchObjectById(goodburg.uuid(),
391391
city -> city.returnReferences(
392392
QueryReference.single("hasAirports")));
393393

@@ -470,7 +470,7 @@ public void testDataTypes() throws IOException {
470470

471471
// Act
472472
var object = types.data.insert(want);
473-
var got = types.query.byId(object.uuid()); // return all properties
473+
var got = types.query.fetchObjectById(object.uuid()); // return all properties
474474

475475
// Assert
476476
Assertions.assertThat(got).get()

src/it/java/io/weaviate/integration/OIDCSupportITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ public void test_resourceOwnerPassword() throws Exception {
103103

104104
@Test
105105
public void test_clientCredentials() throws Exception {
106-
Assume.assumeTrue("OKTA_CLIENT_SECRET is not set", OKTA_CLIENT_SECRET != null && !OKTA_CLIENT_SECRET.isBlank());
106+
Assume.assumeTrue("OKTA_CLIENT_SECRET is not set", OKTA_CLIENT_SECRET != null && OKTA_CLIENT_SECRET.isBlank());
107107
Assume.assumeTrue("no internet connection", hasInternetConnection());
108108

109109
// Check norwal client credentials flow works.
110-
var cc = Authentication.clientCredentials(OKTA_CLIENT_ID, OKTA_CLIENT_SECRET, List.of());
110+
var cc = Authentication.clientCredentials(OKTA_CLIENT_SECRET, List.of());
111111
var auth = SpyTokenProvider.spyOn(cc);
112112
pingWeaviate(oktaContainer, auth);
113113
pingWeaviateAsync(oktaContainer, auth);

src/it/java/io/weaviate/integration/ORMITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public void test_insertAndQuery() throws Exception {
239239
var inserted = things.data.insert(thing);
240240

241241
// Assert
242-
var response = things.query.byId(inserted.uuid());
242+
var response = things.query.fetchObjectById(inserted.uuid());
243243
var got = Assertions.assertThat(response).get().actual();
244244

245245
Assertions.assertThat(got.properties())
@@ -353,7 +353,7 @@ public void test_partialScan() throws IOException {
353353
null));
354354

355355
// Act: return subset of the properties
356-
var got = songs.query.byId(dystopia.uuid(),
356+
var got = songs.query.fetchObjectById(dystopia.uuid(),
357357
q -> q.returnProperties("title", "hasAward"));
358358

359359
// Assert

src/it/java/io/weaviate/integration/ReferencesITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void testReferences() throws IOException {
9090
.extracting(ReferenceProperty::dataTypes, InstanceOfAssertFactories.list(String.class))
9191
.containsOnly(nsMovies);
9292

93-
var gotAlex = artists.query.byId(alex.uuid(),
93+
var gotAlex = artists.query.fetchObjectById(alex.uuid(),
9494
opt -> opt.returnReferences(
9595
QueryReference.multi("hasAwards", nsOscar),
9696
QueryReference.multi("hasAwards", nsGrammy)));
@@ -154,7 +154,7 @@ public void testNestedReferences() throws IOException {
154154
.reference("hasAwards", Reference.objects(grammy_1)));
155155

156156
// Assert: fetch nested references
157-
var gotAlex = artists.query.byId(alex.uuid(),
157+
var gotAlex = artists.query.fetchObjectById(alex.uuid(),
158158
opt -> opt.returnReferences(
159159
QueryReference.single("hasAwards",
160160
ref -> ref

src/it/java/io/weaviate/integration/SearchITest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public void test_includeVectors() throws IOException {
478478
Vectors.of("v3", new float[] { 7, 8, 9 })));
479479

480480
// Act
481-
var got = things.query.byId(
481+
var got = things.query.fetchObjectById(
482482
thing_1.uuid(),
483483
q -> q.includeVector("v1", "v2"));
484484

@@ -595,7 +595,7 @@ public void testGenerative_bm25() throws IOException {
595595
// Act
596596
var french = things.generate.bm25(
597597
"fork",
598-
bm25 -> bm25.queryProperties("title").limit(2),
598+
bm25 -> bm25.queryProperties("title").limit(2).includeVector(),
599599
generate -> generate
600600
.singlePrompt("translate to French")
601601
.groupedTask("count letters R"));
@@ -604,12 +604,18 @@ public void testGenerative_bm25() throws IOException {
604604
Assertions.assertThat(french.objects())
605605
.as("individual results")
606606
.hasSize(2)
607-
.extracting(GenerativeObject::generated)
607+
.allSatisfy(obj -> {
608+
Assertions.assertThat(obj).as("uuid shorthand")
609+
.returns(obj.uuid(), GenerativeObject::uuid);
610+
Assertions.assertThat(obj).as("vectors shorthand")
611+
.returns(obj.vectors(), GenerativeObject::vectors);
612+
})
613+
.extracting(GenerativeObject::generative)
608614
.allSatisfy(generated -> {
609615
Assertions.assertThat(generated.text()).isNotBlank();
610616
});
611617

612-
Assertions.assertThat(french.generated())
618+
Assertions.assertThat(french.generative())
613619
.as("summary")
614620
.extracting(TaskOutput::text, InstanceOfAssertFactories.STRING)
615621
.isNotBlank();
@@ -653,14 +659,14 @@ public void testGenerative_bm25_groupBy() throws IOException {
653659
.describedAs("objects in group %s", groupName)
654660
.hasSize(1);
655661

656-
Assertions.assertThat(group.generated())
662+
Assertions.assertThat(group.generative())
657663
.describedAs("summary group %s", groupName)
658664
.extracting(TaskOutput::text, InstanceOfAssertFactories.STRING)
659665
.isNotBlank();
660666

661667
});
662668

663-
Assertions.assertThat(french.generated())
669+
Assertions.assertThat(french.generative())
664670
.as("summary")
665671
.extracting(TaskOutput::text, InstanceOfAssertFactories.STRING)
666672
.isNotBlank();

src/main/java/io/weaviate/client6/v1/api/Authentication.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,20 @@ public static Authentication resourceOwnerPassword(String username, String passw
5959
/**
6060
* Authenticate using Client Credentials authorization grant.
6161
*
62-
* @param clientId Client ID.
6362
* @param clientSecret Client secret.
6463
* @param scopes Client scopes.
6564
*
6665
* @return Authentication provider.
6766
* @throws WeaviateOAuthException if an error occurred at any point while
6867
* obtaining a new token.
6968
*/
70-
public static Authentication clientCredentials(String clientId, String clientSecret, List<String> scopes) {
69+
public static Authentication clientCredentials(String clientSecret, List<String> scopes) {
7170
return transport -> {
7271
OidcConfig oidc = OidcUtils.getConfig(transport).withScopes(scopes);
7372
if (oidc.scopes().isEmpty() && TokenProvider.isMicrosoft(oidc)) {
74-
oidc = oidc.withScopes(clientId + "/.default");
73+
oidc = oidc.withScopes(oidc.clientId() + "/.default");
7574
}
76-
return TokenProvider.clientCredentials(oidc, clientId, clientSecret);
75+
return TokenProvider.clientCredentials(oidc, clientSecret);
7776
};
7877
}
7978
}

src/main/java/io/weaviate/client6/v1/api/collections/Generative.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,23 @@ public static Generative awsBedrock(String region, String model,
118118
/**
119119
* Configure a default {@code generative-aws} module with Sagemaker integration.
120120
*
121-
* @param region AWS region.
122-
* @param baseUrl Base inference URL.
121+
* @param region AWS region.
122+
* @param endpoint Base inference URL.
123123
*/
124-
public static Generative awsSagemaker(String region, String baseUrl) {
125-
return AwsGenerative.sagemaker(region, baseUrl);
124+
public static Generative awsSagemaker(String region, String endpoint) {
125+
return AwsGenerative.sagemaker(region, endpoint);
126126
}
127127

128128
/**
129129
* Configure a {@code generative-aws} module with Sagemaker integration.
130130
*
131-
* @param region AWS region.
132-
* @param baseUrl Base inference URL.
133-
* @param fn Lambda expression for optional parameters.
131+
* @param region AWS region.
132+
* @param endpoint Base inference URL.
133+
* @param fn Lambda expression for optional parameters.
134134
*/
135-
public static Generative awsSagemaker(String region, String baseUrl,
135+
public static Generative awsSagemaker(String region, String endpoint,
136136
Function<AwsGenerative.SagemakerBuilder, ObjectBuilder<AwsGenerative>> fn) {
137-
return AwsGenerative.sagemaker(region, baseUrl, fn);
137+
return AwsGenerative.sagemaker(region, endpoint, fn);
138138
}
139139

140140
/** Configure a default {@code generative-cohere} module. */
@@ -154,21 +154,21 @@ public static Generative cohere(Function<CohereGenerative.Builder, ObjectBuilder
154154
/**
155155
* Configure a default {@code generative-databricks} module.
156156
*
157-
* @param baseURL Base URL for the generative service.
157+
* @param endpoint Base URL for the generative service.
158158
*/
159-
public static Generative databricks(String baseURL) {
160-
return DatabricksGenerative.of(baseURL);
159+
public static Generative databricks(String endpoint) {
160+
return DatabricksGenerative.of(endpoint);
161161
}
162162

163163
/**
164164
* Configure a {@code generative-databricks} module.
165165
*
166-
* @param baseURL Base URL for the generative service.
167-
* @param fn Lambda expression for optional parameters.
166+
* @param endpoint Base URL for the generative service.
167+
* @param fn Lambda expression for optional parameters.
168168
*/
169-
public static Generative databricks(String baseURL,
169+
public static Generative databricks(String endpoint,
170170
Function<DatabricksGenerative.Builder, ObjectBuilder<DatabricksGenerative>> fn) {
171-
return DatabricksGenerative.of(baseURL, fn);
171+
return DatabricksGenerative.of(endpoint, fn);
172172
}
173173

174174
/** Configure a default {@code generative-frienliai} module. */

src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -619,48 +619,48 @@ public static Map.Entry<String, VectorConfig> text2vecAwsBedrock(String vectorNa
619619
* Create a vector index with an {@code text2vec-aws} vectorizer with Sagemaker
620620
* integration.
621621
*
622-
* @param baseUrl Base URL of the inference service.
622+
* @param endpoint Base URL of the inference service.
623623
*/
624-
public static Map.Entry<String, VectorConfig> text2vecAwsSagemaker(String baseUrl) {
625-
return text2vecAwsSagemaker(VectorIndex.DEFAULT_VECTOR_NAME, baseUrl);
624+
public static Map.Entry<String, VectorConfig> text2vecAwsSagemaker(String endpoint) {
625+
return text2vecAwsSagemaker(VectorIndex.DEFAULT_VECTOR_NAME, endpoint);
626626
}
627627

628628
/**
629629
* Create a vector index with an {@code text2vec-aws} vectorizer with Sagemaker
630630
* integration.
631631
*
632-
* @param baseUrl Base URL of the inference service.
633-
* @param fn Lambda expression for optional parameters.
632+
* @param endpoint Base URL of the inference service.
633+
* @param fn Lambda expression for optional parameters.
634634
*/
635635
public static Map.Entry<String, VectorConfig> text2vecAwsSagemaker(
636-
String baseUrl,
636+
String endpoint,
637637
Function<Text2VecAwsVectorizer.SagemakerBuilder, ObjectBuilder<Text2VecAwsVectorizer>> fn) {
638-
return text2vecAwsSagemaker(VectorIndex.DEFAULT_VECTOR_NAME, baseUrl, fn);
638+
return text2vecAwsSagemaker(VectorIndex.DEFAULT_VECTOR_NAME, endpoint, fn);
639639
}
640640

641641
/**
642642
* Create a named vector index with an {@code text2vec-aws}
643643
* vectorizer with Sagemaker integration.
644644
*
645645
* @param vectorName Vector name.
646-
* @param baseUrl Base URL of the inference service.
646+
* @param endpoint Base URL of the inference service.
647647
*/
648-
public static Map.Entry<String, VectorConfig> text2vecAwsSagemaker(String vectorName, String baseUrl) {
649-
return Map.entry(vectorName, Text2VecAwsVectorizer.sagemaker(baseUrl));
648+
public static Map.Entry<String, VectorConfig> text2vecAwsSagemaker(String vectorName, String endpoint) {
649+
return Map.entry(vectorName, Text2VecAwsVectorizer.sagemaker(endpoint));
650650
}
651651

652652
/**
653653
* Create a named vector index with an {@code text2vec-aws}
654654
* vectorizer with Sagemaker integration.
655655
*
656656
* @param vectorName Vector name.
657-
* @param baseUrl Base URL of the inference service.
657+
* @param endpoint Base URL of the inference service.
658658
* @param fn Lambda expression for optional parameters.
659659
*/
660660
public static Map.Entry<String, VectorConfig> text2vecAwsSagemaker(String vectorName,
661-
String baseUrl,
661+
String endpoint,
662662
Function<Text2VecAwsVectorizer.SagemakerBuilder, ObjectBuilder<Text2VecAwsVectorizer>> fn) {
663-
return Map.entry(vectorName, Text2VecAwsVectorizer.sagemaker(baseUrl, fn));
663+
return Map.entry(vectorName, Text2VecAwsVectorizer.sagemaker(endpoint, fn));
664664
}
665665

666666
/**

src/main/java/io/weaviate/client6/v1/api/collections/data/WeaviateDataClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public InsertManyResponse insertMany(InsertManyRequest<PropertiesT> request) {
7979
}
8080

8181
public boolean exists(String uuid) {
82-
return this.query.byId(uuid).isPresent();
82+
return this.query.fetchObjectById(uuid).isPresent();
8383
}
8484

8585
public void update(

0 commit comments

Comments
 (0)