@lancedb/lancedb 0.18.3-beta.0 → 0.19.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/dist/native.d.ts +5 -3
- package/dist/query.d.ts +120 -2
- package/dist/query.js +207 -3
- package/package.json +10 -8
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ConnectionOptions } from "./native.js";
|
|
|
3
3
|
export { AddColumnsSql, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, OptimizeStats, CompactionStats, RemovalStats, } from "./native.js";
|
|
4
4
|
export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
|
|
5
5
|
export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, } from "./connection";
|
|
6
|
-
export { ExecutableQuery, Query, QueryBase, VectorQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, } from "./query";
|
|
6
|
+
export { ExecutableQuery, Query, QueryBase, VectorQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, FullTextQueryType, } from "./query";
|
|
7
7
|
export { Index, IndexOptions, IvfPqOptions, IvfFlatOptions, HnswPqOptions, HnswSqOptions, FtsOptions, } from "./indices";
|
|
8
8
|
export { Table, AddDataOptions, UpdateOptions, OptimizeOptions, Version, ColumnAlteration, } from "./table";
|
|
9
9
|
export { MergeInsertBuilder } from "./merge";
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.packBits = exports.rerankers = exports.embedding = exports.MergeInsertBuilder = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
|
|
5
|
+
exports.packBits = exports.rerankers = exports.embedding = exports.MergeInsertBuilder = exports.Table = exports.Index = exports.FullTextQueryType = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
|
|
6
6
|
exports.connect = connect;
|
|
7
7
|
const connection_1 = require("./connection");
|
|
8
8
|
const native_js_1 = require("./native.js");
|
|
@@ -17,6 +17,11 @@ Object.defineProperty(exports, "Query", { enumerable: true, get: function () { r
|
|
|
17
17
|
Object.defineProperty(exports, "QueryBase", { enumerable: true, get: function () { return query_1.QueryBase; } });
|
|
18
18
|
Object.defineProperty(exports, "VectorQuery", { enumerable: true, get: function () { return query_1.VectorQuery; } });
|
|
19
19
|
Object.defineProperty(exports, "RecordBatchIterator", { enumerable: true, get: function () { return query_1.RecordBatchIterator; } });
|
|
20
|
+
Object.defineProperty(exports, "MatchQuery", { enumerable: true, get: function () { return query_1.MatchQuery; } });
|
|
21
|
+
Object.defineProperty(exports, "PhraseQuery", { enumerable: true, get: function () { return query_1.PhraseQuery; } });
|
|
22
|
+
Object.defineProperty(exports, "BoostQuery", { enumerable: true, get: function () { return query_1.BoostQuery; } });
|
|
23
|
+
Object.defineProperty(exports, "MultiMatchQuery", { enumerable: true, get: function () { return query_1.MultiMatchQuery; } });
|
|
24
|
+
Object.defineProperty(exports, "FullTextQueryType", { enumerable: true, get: function () { return query_1.FullTextQueryType; } });
|
|
20
25
|
var indices_1 = require("./indices");
|
|
21
26
|
Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return indices_1.Index; } });
|
|
22
27
|
var table_1 = require("./table");
|
package/dist/native.d.ts
CHANGED
|
@@ -208,7 +208,7 @@ export interface ConnectionOptions {
|
|
|
208
208
|
* Note: this consistency only applies to read operations. Write operations are
|
|
209
209
|
* always consistent.
|
|
210
210
|
*/
|
|
211
|
-
readConsistencyInterval?: number
|
|
211
|
+
readConsistencyInterval?: number | null
|
|
212
212
|
/**
|
|
213
213
|
* (For LanceDB OSS only): configuration for object storage.
|
|
214
214
|
*
|
|
@@ -283,7 +283,7 @@ export class NativeMergeInsertBuilder {
|
|
|
283
283
|
}
|
|
284
284
|
export class Query {
|
|
285
285
|
onlyIf(predicate: string): void
|
|
286
|
-
fullTextSearch(query:
|
|
286
|
+
fullTextSearch(query: unknown): void
|
|
287
287
|
select(columns: Array<[string, string]>): void
|
|
288
288
|
selectColumns(columns: Array<string>): void
|
|
289
289
|
limit(limit: number): void
|
|
@@ -293,6 +293,7 @@ export class Query {
|
|
|
293
293
|
withRowId(): void
|
|
294
294
|
execute(maxBatchLength?: number | undefined | null): Promise<RecordBatchIterator>
|
|
295
295
|
explainPlan(verbose: boolean): Promise<string>
|
|
296
|
+
analyzePlan(): Promise<string>
|
|
296
297
|
}
|
|
297
298
|
export class VectorQuery {
|
|
298
299
|
column(column: string): void
|
|
@@ -305,7 +306,7 @@ export class VectorQuery {
|
|
|
305
306
|
ef(ef: number): void
|
|
306
307
|
bypassVectorIndex(): void
|
|
307
308
|
onlyIf(predicate: string): void
|
|
308
|
-
fullTextSearch(query:
|
|
309
|
+
fullTextSearch(query: unknown): void
|
|
309
310
|
select(columns: Array<[string, string]>): void
|
|
310
311
|
selectColumns(columns: Array<string>): void
|
|
311
312
|
limit(limit: number): void
|
|
@@ -315,6 +316,7 @@ export class VectorQuery {
|
|
|
315
316
|
rerank(callbacks: RerankerCallbacks): void
|
|
316
317
|
execute(maxBatchLength?: number | undefined | null): Promise<RecordBatchIterator>
|
|
317
318
|
explainPlan(verbose: boolean): Promise<string>
|
|
319
|
+
analyzePlan(): Promise<string>
|
|
318
320
|
}
|
|
319
321
|
/**
|
|
320
322
|
* Reranker implementation that "wraps" a NodeJS Reranker implementation.
|
package/dist/query.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
68
68
|
* @deprecated Use `where` instead
|
|
69
69
|
*/
|
|
70
70
|
filter(predicate: string): this;
|
|
71
|
-
fullTextSearch(query: string, options?: Partial<FullTextSearchOptions>): this;
|
|
71
|
+
fullTextSearch(query: string | FullTextQuery, options?: Partial<FullTextSearchOptions>): this;
|
|
72
72
|
/**
|
|
73
73
|
* Return only the specified columns.
|
|
74
74
|
*
|
|
@@ -162,6 +162,36 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
162
162
|
* @returns A Promise that resolves to a string containing the query execution plan explanation.
|
|
163
163
|
*/
|
|
164
164
|
explainPlan(verbose?: boolean): Promise<string>;
|
|
165
|
+
/**
|
|
166
|
+
* Executes the query and returns the physical query plan annotated with runtime metrics.
|
|
167
|
+
*
|
|
168
|
+
* This is useful for debugging and performance analysis, as it shows how the query was executed
|
|
169
|
+
* and includes metrics such as elapsed time, rows processed, and I/O statistics.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* import * as lancedb from "@lancedb/lancedb"
|
|
173
|
+
*
|
|
174
|
+
* const db = await lancedb.connect("./.lancedb");
|
|
175
|
+
* const table = await db.createTable("my_table", [
|
|
176
|
+
* { vector: [1.1, 0.9], id: "1" },
|
|
177
|
+
* ]);
|
|
178
|
+
*
|
|
179
|
+
* const plan = await table.query().nearestTo([0.5, 0.2]).analyzePlan();
|
|
180
|
+
*
|
|
181
|
+
* Example output (with runtime metrics inlined):
|
|
182
|
+
* AnalyzeExec verbose=true, metrics=[]
|
|
183
|
+
* ProjectionExec: expr=[id@3 as id, vector@0 as vector, _distance@2 as _distance], metrics=[output_rows=1, elapsed_compute=3.292µs]
|
|
184
|
+
* Take: columns="vector, _rowid, _distance, (id)", metrics=[output_rows=1, elapsed_compute=66.001µs, batches_processed=1, bytes_read=8, iops=1, requests=1]
|
|
185
|
+
* CoalesceBatchesExec: target_batch_size=1024, metrics=[output_rows=1, elapsed_compute=3.333µs]
|
|
186
|
+
* GlobalLimitExec: skip=0, fetch=10, metrics=[output_rows=1, elapsed_compute=167ns]
|
|
187
|
+
* FilterExec: _distance@2 IS NOT NULL, metrics=[output_rows=1, elapsed_compute=8.542µs]
|
|
188
|
+
* SortExec: TopK(fetch=10), expr=[_distance@2 ASC NULLS LAST], metrics=[output_rows=1, elapsed_compute=63.25µs, row_replacements=1]
|
|
189
|
+
* KNNVectorDistance: metric=l2, metrics=[output_rows=1, elapsed_compute=114.333µs, output_batches=1]
|
|
190
|
+
* LanceScan: uri=/path/to/data, projection=[vector], row_id=true, row_addr=false, ordered=false, metrics=[output_rows=1, elapsed_compute=103.626µs, bytes_read=549, iops=2, requests=2]
|
|
191
|
+
*
|
|
192
|
+
* @returns A query execution plan with runtime metrics for each step.
|
|
193
|
+
*/
|
|
194
|
+
analyzePlan(): Promise<string>;
|
|
165
195
|
}
|
|
166
196
|
/**
|
|
167
197
|
* An interface for a query that can be executed
|
|
@@ -356,5 +386,93 @@ export declare class Query extends QueryBase<NativeQuery> {
|
|
|
356
386
|
* a default `limit` of 10 will be used. @see {@link Query#limit}
|
|
357
387
|
*/
|
|
358
388
|
nearestTo(vector: IntoVector): VectorQuery;
|
|
359
|
-
nearestToText(query: string, columns?: string[]): Query;
|
|
389
|
+
nearestToText(query: string | FullTextQuery, columns?: string[]): Query;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Enum representing the types of full-text queries supported.
|
|
393
|
+
*
|
|
394
|
+
* - `Match`: Performs a full-text search for terms in the query string.
|
|
395
|
+
* - `MatchPhrase`: Searches for an exact phrase match in the text.
|
|
396
|
+
* - `Boost`: Boosts the relevance score of specific terms in the query.
|
|
397
|
+
* - `MultiMatch`: Searches across multiple fields for the query terms.
|
|
398
|
+
*/
|
|
399
|
+
export declare enum FullTextQueryType {
|
|
400
|
+
Match = "match",
|
|
401
|
+
MatchPhrase = "match_phrase",
|
|
402
|
+
Boost = "boost",
|
|
403
|
+
MultiMatch = "multi_match"
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Represents a full-text query interface.
|
|
407
|
+
* This interface defines the structure and behavior for full-text queries,
|
|
408
|
+
* including methods to retrieve the query type and convert the query to a dictionary format.
|
|
409
|
+
*/
|
|
410
|
+
export interface FullTextQuery {
|
|
411
|
+
queryType(): FullTextQueryType;
|
|
412
|
+
toDict(): Record<string, unknown>;
|
|
413
|
+
}
|
|
414
|
+
export declare class MatchQuery implements FullTextQuery {
|
|
415
|
+
private query;
|
|
416
|
+
private column;
|
|
417
|
+
private boost;
|
|
418
|
+
private fuzziness;
|
|
419
|
+
private maxExpansions;
|
|
420
|
+
/**
|
|
421
|
+
* Creates an instance of MatchQuery.
|
|
422
|
+
*
|
|
423
|
+
* @param query - The text query to search for.
|
|
424
|
+
* @param column - The name of the column to search within.
|
|
425
|
+
* @param boost - (Optional) The boost factor to influence the relevance score of this query. Default is `1.0`.
|
|
426
|
+
* @param fuzziness - (Optional) The allowed edit distance for fuzzy matching. Default is `0`.
|
|
427
|
+
* @param maxExpansions - (Optional) The maximum number of terms to consider for fuzzy matching. Default is `50`.
|
|
428
|
+
*/
|
|
429
|
+
constructor(query: string, column: string, boost?: number, fuzziness?: number, maxExpansions?: number);
|
|
430
|
+
queryType(): FullTextQueryType;
|
|
431
|
+
toDict(): Record<string, unknown>;
|
|
432
|
+
}
|
|
433
|
+
export declare class PhraseQuery implements FullTextQuery {
|
|
434
|
+
private query;
|
|
435
|
+
private column;
|
|
436
|
+
/**
|
|
437
|
+
* Creates an instance of `PhraseQuery`.
|
|
438
|
+
*
|
|
439
|
+
* @param query - The phrase to search for in the specified column.
|
|
440
|
+
* @param column - The name of the column to search within.
|
|
441
|
+
*/
|
|
442
|
+
constructor(query: string, column: string);
|
|
443
|
+
queryType(): FullTextQueryType;
|
|
444
|
+
toDict(): Record<string, unknown>;
|
|
445
|
+
}
|
|
446
|
+
export declare class BoostQuery implements FullTextQuery {
|
|
447
|
+
private positive;
|
|
448
|
+
private negative;
|
|
449
|
+
private negativeBoost;
|
|
450
|
+
/**
|
|
451
|
+
* Creates an instance of BoostQuery.
|
|
452
|
+
*
|
|
453
|
+
* @param positive - The positive query that boosts the relevance score.
|
|
454
|
+
* @param negative - The negative query that reduces the relevance score.
|
|
455
|
+
* @param negativeBoost - The factor by which the negative query reduces the score.
|
|
456
|
+
*/
|
|
457
|
+
constructor(positive: FullTextQuery, negative: FullTextQuery, negativeBoost: number);
|
|
458
|
+
queryType(): FullTextQueryType;
|
|
459
|
+
toDict(): Record<string, unknown>;
|
|
460
|
+
}
|
|
461
|
+
export declare class MultiMatchQuery implements FullTextQuery {
|
|
462
|
+
private query;
|
|
463
|
+
private columns;
|
|
464
|
+
private boosts;
|
|
465
|
+
/**
|
|
466
|
+
* Creates an instance of MultiMatchQuery.
|
|
467
|
+
*
|
|
468
|
+
* @param query - The text query to search for across multiple columns.
|
|
469
|
+
* @param columns - An array of column names to search within.
|
|
470
|
+
* @param boosts - (Optional) An array of boost factors corresponding to each column. Default is an array of 1.0 for each column.
|
|
471
|
+
*
|
|
472
|
+
* The `boosts` array should have the same length as `columns`. If not provided, all columns will have a default boost of 1.0.
|
|
473
|
+
* If the length of `boosts` is less than `columns`, it will be padded with 1.0s.
|
|
474
|
+
*/
|
|
475
|
+
constructor(query: string, columns: string[], boosts?: number[]);
|
|
476
|
+
queryType(): FullTextQueryType;
|
|
477
|
+
toDict(): Record<string, unknown>;
|
|
360
478
|
}
|
package/dist/query.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.Query = exports.VectorQuery = exports.QueryBase = exports.RecordBatchIterator = void 0;
|
|
5
|
+
exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.FullTextQueryType = exports.Query = exports.VectorQuery = exports.QueryBase = exports.RecordBatchIterator = void 0;
|
|
6
6
|
const arrow_1 = require("./arrow");
|
|
7
7
|
class RecordBatchIterator {
|
|
8
8
|
promisedInner;
|
|
@@ -109,7 +109,19 @@ class QueryBase {
|
|
|
109
109
|
columns = options.columns;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
this.doCall((inner) =>
|
|
112
|
+
this.doCall((inner) => {
|
|
113
|
+
if (typeof query === "string") {
|
|
114
|
+
inner.fullTextSearch({
|
|
115
|
+
query: query,
|
|
116
|
+
columns: columns,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// If query is a FullTextQuery object, convert it to a dict
|
|
121
|
+
const queryObj = query.toDict();
|
|
122
|
+
inner.fullTextSearch(queryObj);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
113
125
|
return this;
|
|
114
126
|
}
|
|
115
127
|
/**
|
|
@@ -278,6 +290,43 @@ class QueryBase {
|
|
|
278
290
|
return this.inner.explainPlan(verbose);
|
|
279
291
|
}
|
|
280
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Executes the query and returns the physical query plan annotated with runtime metrics.
|
|
295
|
+
*
|
|
296
|
+
* This is useful for debugging and performance analysis, as it shows how the query was executed
|
|
297
|
+
* and includes metrics such as elapsed time, rows processed, and I/O statistics.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* import * as lancedb from "@lancedb/lancedb"
|
|
301
|
+
*
|
|
302
|
+
* const db = await lancedb.connect("./.lancedb");
|
|
303
|
+
* const table = await db.createTable("my_table", [
|
|
304
|
+
* { vector: [1.1, 0.9], id: "1" },
|
|
305
|
+
* ]);
|
|
306
|
+
*
|
|
307
|
+
* const plan = await table.query().nearestTo([0.5, 0.2]).analyzePlan();
|
|
308
|
+
*
|
|
309
|
+
* Example output (with runtime metrics inlined):
|
|
310
|
+
* AnalyzeExec verbose=true, metrics=[]
|
|
311
|
+
* ProjectionExec: expr=[id@3 as id, vector@0 as vector, _distance@2 as _distance], metrics=[output_rows=1, elapsed_compute=3.292µs]
|
|
312
|
+
* Take: columns="vector, _rowid, _distance, (id)", metrics=[output_rows=1, elapsed_compute=66.001µs, batches_processed=1, bytes_read=8, iops=1, requests=1]
|
|
313
|
+
* CoalesceBatchesExec: target_batch_size=1024, metrics=[output_rows=1, elapsed_compute=3.333µs]
|
|
314
|
+
* GlobalLimitExec: skip=0, fetch=10, metrics=[output_rows=1, elapsed_compute=167ns]
|
|
315
|
+
* FilterExec: _distance@2 IS NOT NULL, metrics=[output_rows=1, elapsed_compute=8.542µs]
|
|
316
|
+
* SortExec: TopK(fetch=10), expr=[_distance@2 ASC NULLS LAST], metrics=[output_rows=1, elapsed_compute=63.25µs, row_replacements=1]
|
|
317
|
+
* KNNVectorDistance: metric=l2, metrics=[output_rows=1, elapsed_compute=114.333µs, output_batches=1]
|
|
318
|
+
* LanceScan: uri=/path/to/data, projection=[vector], row_id=true, row_addr=false, ordered=false, metrics=[output_rows=1, elapsed_compute=103.626µs, bytes_read=549, iops=2, requests=2]
|
|
319
|
+
*
|
|
320
|
+
* @returns A query execution plan with runtime metrics for each step.
|
|
321
|
+
*/
|
|
322
|
+
async analyzePlan() {
|
|
323
|
+
if (this.inner instanceof Promise) {
|
|
324
|
+
return this.inner.then((inner) => inner.analyzePlan());
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
return this.inner.analyzePlan();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
281
330
|
}
|
|
282
331
|
exports.QueryBase = QueryBase;
|
|
283
332
|
/**
|
|
@@ -583,8 +632,163 @@ class Query extends QueryBase {
|
|
|
583
632
|
}
|
|
584
633
|
}
|
|
585
634
|
nearestToText(query, columns) {
|
|
586
|
-
this.doCall((inner) =>
|
|
635
|
+
this.doCall((inner) => {
|
|
636
|
+
if (typeof query === "string") {
|
|
637
|
+
inner.fullTextSearch({
|
|
638
|
+
query: query,
|
|
639
|
+
columns: columns,
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
const queryObj = query.toDict();
|
|
644
|
+
inner.fullTextSearch(queryObj);
|
|
645
|
+
}
|
|
646
|
+
});
|
|
587
647
|
return this;
|
|
588
648
|
}
|
|
589
649
|
}
|
|
590
650
|
exports.Query = Query;
|
|
651
|
+
/**
|
|
652
|
+
* Enum representing the types of full-text queries supported.
|
|
653
|
+
*
|
|
654
|
+
* - `Match`: Performs a full-text search for terms in the query string.
|
|
655
|
+
* - `MatchPhrase`: Searches for an exact phrase match in the text.
|
|
656
|
+
* - `Boost`: Boosts the relevance score of specific terms in the query.
|
|
657
|
+
* - `MultiMatch`: Searches across multiple fields for the query terms.
|
|
658
|
+
*/
|
|
659
|
+
var FullTextQueryType;
|
|
660
|
+
(function (FullTextQueryType) {
|
|
661
|
+
FullTextQueryType["Match"] = "match";
|
|
662
|
+
FullTextQueryType["MatchPhrase"] = "match_phrase";
|
|
663
|
+
FullTextQueryType["Boost"] = "boost";
|
|
664
|
+
FullTextQueryType["MultiMatch"] = "multi_match";
|
|
665
|
+
})(FullTextQueryType || (exports.FullTextQueryType = FullTextQueryType = {}));
|
|
666
|
+
class MatchQuery {
|
|
667
|
+
query;
|
|
668
|
+
column;
|
|
669
|
+
boost;
|
|
670
|
+
fuzziness;
|
|
671
|
+
maxExpansions;
|
|
672
|
+
/**
|
|
673
|
+
* Creates an instance of MatchQuery.
|
|
674
|
+
*
|
|
675
|
+
* @param query - The text query to search for.
|
|
676
|
+
* @param column - The name of the column to search within.
|
|
677
|
+
* @param boost - (Optional) The boost factor to influence the relevance score of this query. Default is `1.0`.
|
|
678
|
+
* @param fuzziness - (Optional) The allowed edit distance for fuzzy matching. Default is `0`.
|
|
679
|
+
* @param maxExpansions - (Optional) The maximum number of terms to consider for fuzzy matching. Default is `50`.
|
|
680
|
+
*/
|
|
681
|
+
constructor(query, column, boost = 1.0, fuzziness = 0, maxExpansions = 50) {
|
|
682
|
+
this.query = query;
|
|
683
|
+
this.column = column;
|
|
684
|
+
this.boost = boost;
|
|
685
|
+
this.fuzziness = fuzziness;
|
|
686
|
+
this.maxExpansions = maxExpansions;
|
|
687
|
+
}
|
|
688
|
+
queryType() {
|
|
689
|
+
return FullTextQueryType.Match;
|
|
690
|
+
}
|
|
691
|
+
toDict() {
|
|
692
|
+
return {
|
|
693
|
+
[this.queryType()]: {
|
|
694
|
+
[this.column]: {
|
|
695
|
+
query: this.query,
|
|
696
|
+
boost: this.boost,
|
|
697
|
+
fuzziness: this.fuzziness,
|
|
698
|
+
// biome-ignore lint/style/useNamingConvention: use underscore for consistency with the other APIs
|
|
699
|
+
max_expansions: this.maxExpansions,
|
|
700
|
+
},
|
|
701
|
+
},
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
exports.MatchQuery = MatchQuery;
|
|
706
|
+
class PhraseQuery {
|
|
707
|
+
query;
|
|
708
|
+
column;
|
|
709
|
+
/**
|
|
710
|
+
* Creates an instance of `PhraseQuery`.
|
|
711
|
+
*
|
|
712
|
+
* @param query - The phrase to search for in the specified column.
|
|
713
|
+
* @param column - The name of the column to search within.
|
|
714
|
+
*/
|
|
715
|
+
constructor(query, column) {
|
|
716
|
+
this.query = query;
|
|
717
|
+
this.column = column;
|
|
718
|
+
}
|
|
719
|
+
queryType() {
|
|
720
|
+
return FullTextQueryType.MatchPhrase;
|
|
721
|
+
}
|
|
722
|
+
toDict() {
|
|
723
|
+
return {
|
|
724
|
+
[this.queryType()]: {
|
|
725
|
+
[this.column]: this.query,
|
|
726
|
+
},
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
exports.PhraseQuery = PhraseQuery;
|
|
731
|
+
class BoostQuery {
|
|
732
|
+
positive;
|
|
733
|
+
negative;
|
|
734
|
+
negativeBoost;
|
|
735
|
+
/**
|
|
736
|
+
* Creates an instance of BoostQuery.
|
|
737
|
+
*
|
|
738
|
+
* @param positive - The positive query that boosts the relevance score.
|
|
739
|
+
* @param negative - The negative query that reduces the relevance score.
|
|
740
|
+
* @param negativeBoost - The factor by which the negative query reduces the score.
|
|
741
|
+
*/
|
|
742
|
+
constructor(positive, negative, negativeBoost) {
|
|
743
|
+
this.positive = positive;
|
|
744
|
+
this.negative = negative;
|
|
745
|
+
this.negativeBoost = negativeBoost;
|
|
746
|
+
}
|
|
747
|
+
queryType() {
|
|
748
|
+
return FullTextQueryType.Boost;
|
|
749
|
+
}
|
|
750
|
+
toDict() {
|
|
751
|
+
return {
|
|
752
|
+
[this.queryType()]: {
|
|
753
|
+
positive: this.positive.toDict(),
|
|
754
|
+
negative: this.negative.toDict(),
|
|
755
|
+
// biome-ignore lint/style/useNamingConvention: use underscore for consistency with the other APIs
|
|
756
|
+
negative_boost: this.negativeBoost,
|
|
757
|
+
},
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
exports.BoostQuery = BoostQuery;
|
|
762
|
+
class MultiMatchQuery {
|
|
763
|
+
query;
|
|
764
|
+
columns;
|
|
765
|
+
boosts;
|
|
766
|
+
/**
|
|
767
|
+
* Creates an instance of MultiMatchQuery.
|
|
768
|
+
*
|
|
769
|
+
* @param query - The text query to search for across multiple columns.
|
|
770
|
+
* @param columns - An array of column names to search within.
|
|
771
|
+
* @param boosts - (Optional) An array of boost factors corresponding to each column. Default is an array of 1.0 for each column.
|
|
772
|
+
*
|
|
773
|
+
* The `boosts` array should have the same length as `columns`. If not provided, all columns will have a default boost of 1.0.
|
|
774
|
+
* If the length of `boosts` is less than `columns`, it will be padded with 1.0s.
|
|
775
|
+
*/
|
|
776
|
+
constructor(query, columns, boosts = columns.map(() => 1.0)) {
|
|
777
|
+
this.query = query;
|
|
778
|
+
this.columns = columns;
|
|
779
|
+
this.boosts = boosts;
|
|
780
|
+
}
|
|
781
|
+
queryType() {
|
|
782
|
+
return FullTextQueryType.MultiMatch;
|
|
783
|
+
}
|
|
784
|
+
toDict() {
|
|
785
|
+
return {
|
|
786
|
+
[this.queryType()]: {
|
|
787
|
+
query: this.query,
|
|
788
|
+
columns: this.columns,
|
|
789
|
+
boost: this.boosts,
|
|
790
|
+
},
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
exports.MultiMatchQuery = MultiMatchQuery;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"ann"
|
|
12
12
|
],
|
|
13
13
|
"private": false,
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.19.0-beta.3",
|
|
15
15
|
"main": "dist/index.js",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./dist/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"aarch64-apple-darwin",
|
|
30
30
|
"x86_64-unknown-linux-gnu",
|
|
31
31
|
"aarch64-unknown-linux-gnu",
|
|
32
|
+
"x86_64-unknown-linux-musl",
|
|
32
33
|
"aarch64-unknown-linux-musl",
|
|
33
34
|
"x86_64-pc-windows-msvc",
|
|
34
35
|
"aarch64-pc-windows-msvc"
|
|
@@ -99,13 +100,14 @@
|
|
|
99
100
|
"reflect-metadata": "^0.2.2"
|
|
100
101
|
},
|
|
101
102
|
"optionalDependencies": {
|
|
102
|
-
"@lancedb/lancedb-darwin-x64": "0.
|
|
103
|
-
"@lancedb/lancedb-darwin-arm64": "0.
|
|
104
|
-
"@lancedb/lancedb-linux-x64-gnu": "0.
|
|
105
|
-
"@lancedb/lancedb-linux-arm64-gnu": "0.
|
|
106
|
-
"@lancedb/lancedb-linux-
|
|
107
|
-
"@lancedb/lancedb-
|
|
108
|
-
"@lancedb/lancedb-win32-
|
|
103
|
+
"@lancedb/lancedb-darwin-x64": "0.19.0-beta.3",
|
|
104
|
+
"@lancedb/lancedb-darwin-arm64": "0.19.0-beta.3",
|
|
105
|
+
"@lancedb/lancedb-linux-x64-gnu": "0.19.0-beta.3",
|
|
106
|
+
"@lancedb/lancedb-linux-arm64-gnu": "0.19.0-beta.3",
|
|
107
|
+
"@lancedb/lancedb-linux-x64-musl": "0.19.0-beta.3",
|
|
108
|
+
"@lancedb/lancedb-linux-arm64-musl": "0.19.0-beta.3",
|
|
109
|
+
"@lancedb/lancedb-win32-x64-msvc": "0.19.0-beta.3",
|
|
110
|
+
"@lancedb/lancedb-win32-arm64-msvc": "0.19.0-beta.3"
|
|
109
111
|
},
|
|
110
112
|
"peerDependencies": {
|
|
111
113
|
"apache-arrow": ">=15.0.0 <=18.1.0"
|