Skip to content

Commit 64cbfc4

Browse files
committed
RDBC-918 Refactor vectorSearch function to improve naming consistency and enhance code readability in tests and session queries
1 parent 1799c9f commit 64cbfc4

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

src/Documents/Session/VectorFieldFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export interface IVectorEmbeddingTextFieldValueFactory {
8686

8787
/**
8888
* Query by the embedding(s) indexed from the specified document for the quried field.
89-
* @param documentId Document id
89+
* @param documentId The unique identifier of the document to be processed.
9090
*/
9191
forDocument(documentId: string): void;
9292

test/Documents/Queries/VectorSearchTest.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import {
66
IndexDefinition,
77
PutIndexesOperation
88
} from "../../../src/index.js";
9-
import {disposeTestDocumentStore, testContext} from "../../Utils/TestUtil.js";
9+
import {disposeTestDocumentStore, RavenTestContext, testContext} from "../../Utils/TestUtil.js";
1010
import {assertThat} from "../../Utils/AssertExtensions.js";
1111

1212

13-
describe("RDBC-899", function () {
13+
(RavenTestContext.is70Server ? describe : describe.skip)("RDBC-899", function () {
1414
let store: IDocumentStore;
1515

1616
beforeEach(async function () {
@@ -24,7 +24,7 @@ describe("RDBC-899", function () {
2424
const session = store.openSession();
2525

2626
const query = session.query<Dto>({collection: "Dtos"})
27-
.vectorSearch(x => x.withEmbedding("EmbeddingField", "Int8").targetQuantization("Int8"),
27+
.vectorSearch(field => field.withEmbedding("EmbeddingField", "Int8").targetQuantization("Int8"),
2828
factory => factory.byEmbedding([2.5, 3.3]), {
2929
similarity: 0.65,
3030
numberOfCandidates: 12
@@ -38,7 +38,7 @@ describe("RDBC-899", function () {
3838
const session = store.openSession();
3939

4040
const query = session.query<Dto>({collection: "Dtos"})
41-
.vectorSearch(x => x.withText("VectorField").usingTask("id-for-task-open-ai"),
41+
.vectorSearch(field => field.withText("VectorField").usingTask("id-for-task-open-ai"),
4242
factory => factory.byText("aaaa"))
4343
.toString();
4444

@@ -49,7 +49,7 @@ describe("RDBC-899", function () {
4949
const session = store.openSession();
5050

5151
const query = session.query<Dto>({collection: "Dtos"})
52-
.vectorSearch(x => x.withField("VectorField"),
52+
.vectorSearch(field => field.withField("VectorField"),
5353
factory => factory.byEmbedding([0.3, 0.4, 0.5]))
5454
.toString();
5555

@@ -60,7 +60,7 @@ describe("RDBC-899", function () {
6060
const session = store.openSession();
6161

6262
const query = session.query<Dto>({collection: "Dtos"})
63-
.vectorSearch(x => x.withField("VectorField"),
63+
.vectorSearch(field => field.withField("VectorField"),
6464
factory => factory.byBase64("aaaa=="))
6565
.toString();
6666

@@ -71,7 +71,7 @@ describe("RDBC-899", function () {
7171
const session = store.openSession();
7272

7373
const query = session.query<Dto>({collection: "Dtos"})
74-
.vectorSearch(x => x.withText("EmbeddingSingles").targetQuantization("Int8"),
74+
.vectorSearch(field => field.withText("EmbeddingSingles").targetQuantization("Int8"),
7575
factory => factory.byText("aaaa"))
7676
.toString();
7777

@@ -82,7 +82,7 @@ describe("RDBC-899", function () {
8282
const session = store.openSession();
8383

8484
const query = session.query<Dto>({collection: "Dtos"})
85-
.vectorSearch(x => x.withEmbedding("EmbeddingSingles"),
85+
.vectorSearch(field => field.withEmbedding("EmbeddingSingles"),
8686
factory => factory.byEmbedding([0.1, 0.2, 0.3]))
8787
.toString();
8888

@@ -93,7 +93,7 @@ describe("RDBC-899", function () {
9393
const session = store.openSession();
9494

9595
const query = session.query<Dto>({collection: "Dtos"})
96-
.vectorSearch(x => x.withEmbedding("EmbeddingSBytes", "Int8"),
96+
.vectorSearch(field => field.withEmbedding("EmbeddingSBytes", "Int8"),
9797
factory => factory.byEmbedding([1, 2, 3]), {
9898
similarity: 0.75
9999
})
@@ -106,7 +106,7 @@ describe("RDBC-899", function () {
106106
const session = store.openSession();
107107

108108
const query = session.query<Dto>({collection: "Dtos"})
109-
.vectorSearch(x => x.withEmbedding("EmbeddingBinary", "Binary"),
109+
.vectorSearch(field => field.withEmbedding("EmbeddingBinary", "Binary"),
110110
factory => factory.byEmbedding([0, 1, 0, 1]))
111111
.toString();
112112

@@ -117,7 +117,7 @@ describe("RDBC-899", function () {
117117
const session = store.openSession();
118118

119119
const query = session.query<Dto>({collection: "Dtos"})
120-
.vectorSearch(x => x.withText("TextualValue"),
120+
.vectorSearch(field => field.withText("TextualValue"),
121121
factory => factory.byText("search text"))
122122
.toString();
123123

@@ -128,7 +128,7 @@ describe("RDBC-899", function () {
128128
const session = store.openSession();
129129

130130
const query = session.query<Dto>({collection: "Dtos"})
131-
.vectorSearch(x => x.withText("TextualValue").usingTask("taskId-123"),
131+
.vectorSearch(field => field.withText("TextualValue").usingTask("taskId-123"),
132132
factory => factory.byText("query text"))
133133
.toString();
134134

@@ -139,7 +139,7 @@ describe("RDBC-899", function () {
139139
const session = store.openSession();
140140

141141
const query = session.query<Dto>({collection: "Dtos"})
142-
.vectorSearch(x => x.withBase64("EmbeddingBase64"),
142+
.vectorSearch(field => field.withBase64("EmbeddingBase64"),
143143
factory => factory.byBase64("aGVsbG8="))
144144
.toString();
145145

@@ -150,7 +150,7 @@ describe("RDBC-899", function () {
150150
const session = store.openSession();
151151

152152
const query = session.query<Dto>({collection: "Dtos"})
153-
.vectorSearch(x => x.withEmbedding("EmbeddingSingles").targetQuantization("Int8"),
153+
.vectorSearch(field => field.withEmbedding("EmbeddingSingles").targetQuantization("Int8"),
154154
factory => factory.byEmbedding([0.1, 0.2, 0.3]))
155155
.toString();
156156

@@ -161,7 +161,7 @@ describe("RDBC-899", function () {
161161
const session = store.openSession();
162162

163163
const query = session.query<Dto>({collection: "Dtos"})
164-
.vectorSearch(x => x.withEmbedding("EmbeddingSingles").targetQuantization("Binary"),
164+
.vectorSearch(field => field.withEmbedding("EmbeddingSingles").targetQuantization("Binary"),
165165
factory => factory.byEmbedding([0.1, 0.2, 0.3]))
166166
.toString();
167167

@@ -172,7 +172,7 @@ describe("RDBC-899", function () {
172172
const session = store.openSession();
173173

174174
const query = session.query<Dto>({collection: "Dtos"})
175-
.vectorSearch(x => x.withText("TextualValue").targetQuantization("Int8"),
175+
.vectorSearch(field => field.withText("TextualValue").targetQuantization("Int8"),
176176
factory => factory.byText("query text"))
177177
.toString();
178178

@@ -183,7 +183,7 @@ describe("RDBC-899", function () {
183183
const session = store.openSession();
184184

185185
const query = session.query<Dto>({collection: "Dtos"})
186-
.vectorSearch(x => x.withText("TextualValue")
186+
.vectorSearch(field => field.withText("TextualValue")
187187
.usingTask("openai-embeddings")
188188
.targetQuantization("Binary"),
189189
factory => factory.byText("query text"))
@@ -196,7 +196,7 @@ describe("RDBC-899", function () {
196196
const session = store.openSession();
197197

198198
const query = session.query<Dto>({collection: "Dtos"})
199-
.vectorSearch(x => x.withField("EmbeddingSingles"),
199+
.vectorSearch(field => field.withField("EmbeddingSingles"),
200200
factory => factory.byEmbedding([0.1, 0.2, 0.3]), {
201201
numberOfCandidates: 20
202202
})
@@ -209,7 +209,7 @@ describe("RDBC-899", function () {
209209
const session = store.openSession();
210210

211211
const query = session.query<Dto>({collection: "Dtos"})
212-
.vectorSearch(x => x.withField("VectorField"),
212+
.vectorSearch(field => field.withField("VectorField"),
213213
factory => factory.byEmbedding([0.3, 0.4, 0.5]), {
214214
isExact: true
215215
})
@@ -222,7 +222,7 @@ describe("RDBC-899", function () {
222222
const session = store.openSession();
223223

224224
const query = session.query<Dto>({collection: "Dtos"})
225-
.vectorSearch(x => x.withField("VectorField"),
225+
.vectorSearch(field => field.withField("VectorField"),
226226
factory => factory.byEmbedding([0.3, 0.4, 0.5]), {
227227
similarity: 0.75,
228228
numberOfCandidates: 50,
@@ -237,7 +237,7 @@ describe("RDBC-899", function () {
237237
const session = store.openSession();
238238

239239
const query = session.query<Dto>({collection: "Dtos"})
240-
.vectorSearch(x => x.withEmbedding("EmbeddingSingles"),
240+
.vectorSearch(field => field.withEmbedding("EmbeddingSingles"),
241241
factory => factory.byEmbedding([0.1, 0.2, 0.3]), {
242242
isExact: true
243243
})
@@ -250,7 +250,7 @@ describe("RDBC-899", function () {
250250
const session = store.openSession();
251251

252252
const query = session.query<Dto>({collection: "Dtos"})
253-
.vectorSearch(x => x.withText("TextualValue"),
253+
.vectorSearch(field => field.withText("TextualValue"),
254254
factory => factory.byText("query text"), {
255255
similarity: 0.8,
256256
isExact: true
@@ -264,7 +264,7 @@ describe("RDBC-899", function () {
264264
const session = store.openSession();
265265

266266
const query = session.query<Dto>({collection: "Dtos"})
267-
.vectorSearch(x => x.withText("TextualValue"),
267+
.vectorSearch(field => field.withText("TextualValue"),
268268
factory => factory.byTexts(["first query", "second query"]), {
269269
similarity: 0.75
270270
})
@@ -277,7 +277,7 @@ describe("RDBC-899", function () {
277277
const session = store.openSession();
278278

279279
const query = session.query<Dto>({collection: "Dtos"})
280-
.vectorSearch(x => x.withField("EmbeddingSingles"),
280+
.vectorSearch(field => field.withField("EmbeddingSingles"),
281281
factory => factory.byEmbeddings([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]]), {
282282
numberOfCandidates: 30
283283
})
@@ -290,7 +290,7 @@ describe("RDBC-899", function () {
290290
const session = store.openSession();
291291

292292
const query = session.query<Dto>({collection: "Dtos"})
293-
.vectorSearch(x => x.withEmbedding("EmbeddingSBytes", "Int8").targetQuantization("Int8"),
293+
.vectorSearch(field => field.withEmbedding("EmbeddingSBytes", "Int8").targetQuantization("Int8"),
294294
factory => factory.byEmbeddings([[1, 2, 3], [4, 5, 6]]))
295295
.toString();
296296

@@ -301,7 +301,7 @@ describe("RDBC-899", function () {
301301
const session = store.openSession();
302302

303303
const query = session.query<Dto>({collection: "Dtos"})
304-
.vectorSearch(x => x.withText("TextualValue")
304+
.vectorSearch(field => field.withText("TextualValue")
305305
.usingTask("openai-embeddings")
306306
.targetQuantization("Binary"),
307307
factory => factory.byTexts(["query one", "query two", "query three"]), {
@@ -389,7 +389,7 @@ describe("RDBC-899", function () {
389389
const session = store.openSession();
390390

391391
const query = session.query<Dto>({collection: "Dtos"})
392-
.vectorSearch(x => x.withText("TextualValue"),
392+
.vectorSearch(field => field.withText("TextualValue"),
393393
factory => factory.forDocument("dtos/456"))
394394
.toString();
395395

@@ -400,7 +400,7 @@ describe("RDBC-899", function () {
400400
const session = store.openSession();
401401

402402
const query = session.query<Dto>({collection: "Dtos"})
403-
.vectorSearch(x => x.withEmbedding("EmbeddingSBytes", "Int8"),
403+
.vectorSearch(field => field.withEmbedding("EmbeddingSBytes", "Int8"),
404404
factory => factory.forDocument("dtos/int8-test"))
405405
.toString();
406406

@@ -412,7 +412,7 @@ describe("RDBC-899", function () {
412412
const session = store.openSession();
413413

414414
const query = session.query<Dto>({collection: "Dtos"})
415-
.vectorSearch(x => x.withText("TextualValue").usingTask("openai-task"),
415+
.vectorSearch(field => field.withText("TextualValue").usingTask("openai-task"),
416416
factory => factory.forDocument("dtos/789"))
417417
.toString();
418418

@@ -423,7 +423,7 @@ describe("RDBC-899", function () {
423423
const session = store.openSession();
424424

425425
const query = session.query<Dto>({collection: "Dtos"})
426-
.vectorSearch(x => x.withEmbedding("EmbeddingSingles"),
426+
.vectorSearch(field => field.withEmbedding("EmbeddingSingles"),
427427
factory => factory.forDocument("dtos/full-options"), {
428428
similarity: 0.75,
429429
numberOfCandidates: 100
@@ -438,7 +438,7 @@ describe("RDBC-899", function () {
438438
const session = store.openSession();
439439

440440
const query = session.query<Dto>({collection: "Dtos"})
441-
.vectorSearch(x => x.withField("VectorField"),
441+
.vectorSearch(field => field.withField("VectorField"),
442442
factory => factory.forDocument("dtos/candidates-test"), {
443443
numberOfCandidates: 50
444444
})

0 commit comments

Comments
 (0)