@lancedb/lancedb 0.21.2 → 0.21.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/arrow.js +19 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/native.d.ts +18 -0
- package/dist/native.js +2 -1
- package/dist/query.d.ts +55 -39
- package/dist/query.js +96 -74
- package/dist/table.d.ts +15 -1
- package/dist/table.js +6 -0
- package/package.json +10 -10
package/dist/arrow.js
CHANGED
|
@@ -56,6 +56,13 @@ exports.dataTypeToJson = dataTypeToJson;
|
|
|
56
56
|
const apache_arrow_1 = require("apache-arrow");
|
|
57
57
|
const registry_1 = require("./embedding/registry");
|
|
58
58
|
const sanitize_1 = require("./sanitize");
|
|
59
|
+
/**
|
|
60
|
+
* Check if a field name indicates a vector column.
|
|
61
|
+
*/
|
|
62
|
+
function nameSuggestsVectorColumn(fieldName) {
|
|
63
|
+
const nameLower = fieldName.toLowerCase();
|
|
64
|
+
return nameLower.includes("vector") || nameLower.includes("embedding");
|
|
65
|
+
}
|
|
59
66
|
__exportStar(require("apache-arrow"), exports);
|
|
60
67
|
function isMultiVector(value) {
|
|
61
68
|
return Array.isArray(value) && isIntoVector(value[0]);
|
|
@@ -494,10 +501,18 @@ function inferType(value, path, opts) {
|
|
|
494
501
|
return undefined;
|
|
495
502
|
}
|
|
496
503
|
// Try to automatically detect embedding columns.
|
|
497
|
-
if (
|
|
498
|
-
//
|
|
499
|
-
|
|
500
|
-
|
|
504
|
+
if (nameSuggestsVectorColumn(path[path.length - 1])) {
|
|
505
|
+
// Check if value is a Uint8Array for integer vector type determination
|
|
506
|
+
if (value instanceof Uint8Array) {
|
|
507
|
+
// For integer vectors, we default to Uint8 (matching Python implementation)
|
|
508
|
+
const child = new apache_arrow_1.Field("item", new apache_arrow_1.Uint8(), true);
|
|
509
|
+
return new apache_arrow_1.FixedSizeList(value.length, child);
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
// For float vectors, we default to Float32
|
|
513
|
+
const child = new apache_arrow_1.Field("item", new apache_arrow_1.Float32(), true);
|
|
514
|
+
return new apache_arrow_1.FixedSizeList(value.length, child);
|
|
515
|
+
}
|
|
501
516
|
}
|
|
502
517
|
else {
|
|
503
518
|
const child = new apache_arrow_1.Field("item", valueType, true);
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { AddColumnsSql, ConnectionOptions, IndexStatistics, IndexConfig, ClientC
|
|
|
4
4
|
export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
|
|
5
5
|
export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, } from "./connection";
|
|
6
6
|
export { Session } from "./native.js";
|
|
7
|
-
export { ExecutableQuery, Query, QueryBase, VectorQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, BooleanQuery, FullTextQueryType, Operator, Occur, } from "./query";
|
|
7
|
+
export { ExecutableQuery, Query, QueryBase, VectorQuery, TakeQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, BooleanQuery, FullTextQueryType, Operator, Occur, } from "./query";
|
|
8
8
|
export { Index, IndexOptions, IvfPqOptions, IvfFlatOptions, HnswPqOptions, HnswSqOptions, FtsOptions, } from "./indices";
|
|
9
9
|
export { Table, AddDataOptions, UpdateOptions, OptimizeOptions, Version, ColumnAlteration, } from "./table";
|
|
10
10
|
export { MergeInsertBuilder, WriteExecutionOptions } 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.Occur = exports.Operator = exports.FullTextQueryType = exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Session = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.TagContents = exports.Tags = void 0;
|
|
5
|
+
exports.packBits = exports.rerankers = exports.embedding = exports.MergeInsertBuilder = exports.Table = exports.Index = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.RecordBatchIterator = exports.TakeQuery = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Session = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.TagContents = exports.Tags = void 0;
|
|
6
6
|
exports.connect = connect;
|
|
7
7
|
const connection_1 = require("./connection");
|
|
8
8
|
const native_js_1 = require("./native.js");
|
|
@@ -21,6 +21,7 @@ var query_1 = require("./query");
|
|
|
21
21
|
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_1.Query; } });
|
|
22
22
|
Object.defineProperty(exports, "QueryBase", { enumerable: true, get: function () { return query_1.QueryBase; } });
|
|
23
23
|
Object.defineProperty(exports, "VectorQuery", { enumerable: true, get: function () { return query_1.VectorQuery; } });
|
|
24
|
+
Object.defineProperty(exports, "TakeQuery", { enumerable: true, get: function () { return query_1.TakeQuery; } });
|
|
24
25
|
Object.defineProperty(exports, "RecordBatchIterator", { enumerable: true, get: function () { return query_1.RecordBatchIterator; } });
|
|
25
26
|
Object.defineProperty(exports, "MatchQuery", { enumerable: true, get: function () { return query_1.MatchQuery; } });
|
|
26
27
|
Object.defineProperty(exports, "PhraseQuery", { enumerable: true, get: function () { return query_1.PhraseQuery; } });
|
package/dist/native.d.ts
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
/** Timeout configuration for remote HTTP client. */
|
|
7
7
|
export interface TimeoutConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The overall timeout for the entire request in seconds. This includes
|
|
10
|
+
* connection, send, and read time. If the entire request doesn't complete
|
|
11
|
+
* within this time, it will fail. Default is None (no overall timeout).
|
|
12
|
+
* This can also be set via the environment variable `LANCE_CLIENT_TIMEOUT`,
|
|
13
|
+
* as an integer number of seconds.
|
|
14
|
+
*/
|
|
15
|
+
timeout?: number
|
|
8
16
|
/**
|
|
9
17
|
* The timeout for establishing a connection in seconds. Default is 120
|
|
10
18
|
* seconds (2 minutes). This can also be set via the environment variable
|
|
@@ -385,6 +393,14 @@ export class VectorQuery {
|
|
|
385
393
|
explainPlan(verbose: boolean): Promise<string>
|
|
386
394
|
analyzePlan(): Promise<string>
|
|
387
395
|
}
|
|
396
|
+
export class TakeQuery {
|
|
397
|
+
select(columns: Array<[string, string]>): void
|
|
398
|
+
selectColumns(columns: Array<string>): void
|
|
399
|
+
withRowId(): void
|
|
400
|
+
execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
|
|
401
|
+
explainPlan(verbose: boolean): Promise<string>
|
|
402
|
+
analyzePlan(): Promise<string>
|
|
403
|
+
}
|
|
388
404
|
export class JsFullTextQuery {
|
|
389
405
|
static matchQuery(query: string, column: string, boost: number, fuzziness: number | undefined | null, maxExpansions: number, operator: string, prefixLength: number): JsFullTextQuery
|
|
390
406
|
static phraseQuery(query: string, column: string, slop: number): JsFullTextQuery
|
|
@@ -459,6 +475,8 @@ export class Table {
|
|
|
459
475
|
stats(): Promise<TableStatistics>
|
|
460
476
|
update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<UpdateResult>
|
|
461
477
|
query(): Query
|
|
478
|
+
takeOffsets(offsets: Array<number>): TakeQuery
|
|
479
|
+
takeRowIds(rowIds: Array<number>): TakeQuery
|
|
462
480
|
vectorSearch(vector: Float32Array): VectorQuery
|
|
463
481
|
addColumns(transforms: Array<AddColumnsSql>): Promise<AddColumnsResult>
|
|
464
482
|
alterColumns(alterations: Array<ColumnAlteration>): Promise<AlterColumnsResult>
|
package/dist/native.js
CHANGED
|
@@ -319,13 +319,14 @@ if (!nativeBinding) {
|
|
|
319
319
|
}
|
|
320
320
|
throw new Error(`Failed to load native binding`);
|
|
321
321
|
}
|
|
322
|
-
const { Connection, Index, RecordBatchIterator, NativeMergeInsertBuilder, Query, VectorQuery, JsFullTextQuery, Reranker, RrfReranker, Session, Table, TagContents, Tags } = nativeBinding;
|
|
322
|
+
const { Connection, Index, RecordBatchIterator, NativeMergeInsertBuilder, Query, VectorQuery, TakeQuery, JsFullTextQuery, Reranker, RrfReranker, Session, Table, TagContents, Tags } = nativeBinding;
|
|
323
323
|
module.exports.Connection = Connection;
|
|
324
324
|
module.exports.Index = Index;
|
|
325
325
|
module.exports.RecordBatchIterator = RecordBatchIterator;
|
|
326
326
|
module.exports.NativeMergeInsertBuilder = NativeMergeInsertBuilder;
|
|
327
327
|
module.exports.Query = Query;
|
|
328
328
|
module.exports.VectorQuery = VectorQuery;
|
|
329
|
+
module.exports.TakeQuery = TakeQuery;
|
|
329
330
|
module.exports.JsFullTextQuery = JsFullTextQuery;
|
|
330
331
|
module.exports.Reranker = Reranker;
|
|
331
332
|
module.exports.RrfReranker = RrfReranker;
|
package/dist/query.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Table as ArrowTable, type IntoVector, RecordBatch } from "./arrow";
|
|
2
2
|
import { type IvfPqOptions } from "./indices";
|
|
3
|
-
import { JsFullTextQuery, RecordBatchIterator as NativeBatchIterator, Query as NativeQuery, Table as NativeTable, VectorQuery as NativeVectorQuery } from "./native";
|
|
3
|
+
import { JsFullTextQuery, RecordBatchIterator as NativeBatchIterator, Query as NativeQuery, Table as NativeTable, TakeQuery as NativeTakeQuery, VectorQuery as NativeVectorQuery } from "./native";
|
|
4
4
|
import { Reranker } from "./rerankers";
|
|
5
5
|
export declare class RecordBatchIterator implements AsyncIterator<RecordBatch> {
|
|
6
6
|
private promisedInner?;
|
|
@@ -43,7 +43,7 @@ export interface FullTextSearchOptions {
|
|
|
43
43
|
*
|
|
44
44
|
* @hideconstructor
|
|
45
45
|
*/
|
|
46
|
-
export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVectorQuery> implements AsyncIterable<RecordBatch> {
|
|
46
|
+
export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVectorQuery | NativeTakeQuery> implements AsyncIterable<RecordBatch> {
|
|
47
47
|
protected inner: NativeQueryType | Promise<NativeQueryType>;
|
|
48
48
|
/**
|
|
49
49
|
* @hidden
|
|
@@ -53,26 +53,6 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
53
53
|
* @hidden
|
|
54
54
|
*/
|
|
55
55
|
protected doCall(fn: (inner: NativeQueryType) => void): void;
|
|
56
|
-
/**
|
|
57
|
-
* A filter statement to be applied to this query.
|
|
58
|
-
*
|
|
59
|
-
* The filter should be supplied as an SQL query string. For example:
|
|
60
|
-
* @example
|
|
61
|
-
* x > 10
|
|
62
|
-
* y > 0 AND y < 100
|
|
63
|
-
* x > 5 OR y = 'test'
|
|
64
|
-
*
|
|
65
|
-
* Filtering performance can often be improved by creating a scalar index
|
|
66
|
-
* on the filter column(s).
|
|
67
|
-
*/
|
|
68
|
-
where(predicate: string): this;
|
|
69
|
-
/**
|
|
70
|
-
* A filter statement to be applied to this query.
|
|
71
|
-
* @see where
|
|
72
|
-
* @deprecated Use `where` instead
|
|
73
|
-
*/
|
|
74
|
-
filter(predicate: string): this;
|
|
75
|
-
fullTextSearch(query: string | FullTextQuery, options?: Partial<FullTextSearchOptions>): this;
|
|
76
56
|
/**
|
|
77
57
|
* Return only the specified columns.
|
|
78
58
|
*
|
|
@@ -104,21 +84,6 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
104
84
|
* object insertion order is easy to get wrong and `Map` is more foolproof.
|
|
105
85
|
*/
|
|
106
86
|
select(columns: string[] | Map<string, string> | Record<string, string> | string): this;
|
|
107
|
-
/**
|
|
108
|
-
* Set the maximum number of results to return.
|
|
109
|
-
*
|
|
110
|
-
* By default, a plain search has no limit. If this method is not
|
|
111
|
-
* called then every valid row from the table will be returned.
|
|
112
|
-
*/
|
|
113
|
-
limit(limit: number): this;
|
|
114
|
-
offset(offset: number): this;
|
|
115
|
-
/**
|
|
116
|
-
* Skip searching un-indexed data. This can make search faster, but will miss
|
|
117
|
-
* any data that is not yet indexed.
|
|
118
|
-
*
|
|
119
|
-
* Use {@link Table#optimize} to index all un-indexed data.
|
|
120
|
-
*/
|
|
121
|
-
fastSearch(): this;
|
|
122
87
|
/**
|
|
123
88
|
* Whether to return the row id in the results.
|
|
124
89
|
*
|
|
@@ -197,6 +162,49 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
197
162
|
*/
|
|
198
163
|
analyzePlan(): Promise<string>;
|
|
199
164
|
}
|
|
165
|
+
export declare class StandardQueryBase<NativeQueryType extends NativeQuery | NativeVectorQuery> extends QueryBase<NativeQueryType> implements ExecutableQuery {
|
|
166
|
+
constructor(inner: NativeQueryType | Promise<NativeQueryType>);
|
|
167
|
+
/**
|
|
168
|
+
* A filter statement to be applied to this query.
|
|
169
|
+
*
|
|
170
|
+
* The filter should be supplied as an SQL query string. For example:
|
|
171
|
+
* @example
|
|
172
|
+
* x > 10
|
|
173
|
+
* y > 0 AND y < 100
|
|
174
|
+
* x > 5 OR y = 'test'
|
|
175
|
+
*
|
|
176
|
+
* Filtering performance can often be improved by creating a scalar index
|
|
177
|
+
* on the filter column(s).
|
|
178
|
+
*/
|
|
179
|
+
where(predicate: string): this;
|
|
180
|
+
/**
|
|
181
|
+
* A filter statement to be applied to this query.
|
|
182
|
+
* @see where
|
|
183
|
+
* @deprecated Use `where` instead
|
|
184
|
+
*/
|
|
185
|
+
filter(predicate: string): this;
|
|
186
|
+
fullTextSearch(query: string | FullTextQuery, options?: Partial<FullTextSearchOptions>): this;
|
|
187
|
+
/**
|
|
188
|
+
* Set the maximum number of results to return.
|
|
189
|
+
*
|
|
190
|
+
* By default, a plain search has no limit. If this method is not
|
|
191
|
+
* called then every valid row from the table will be returned.
|
|
192
|
+
*/
|
|
193
|
+
limit(limit: number): this;
|
|
194
|
+
/**
|
|
195
|
+
* Set the number of rows to skip before returning results.
|
|
196
|
+
*
|
|
197
|
+
* This is useful for pagination.
|
|
198
|
+
*/
|
|
199
|
+
offset(offset: number): this;
|
|
200
|
+
/**
|
|
201
|
+
* Skip searching un-indexed data. This can make search faster, but will miss
|
|
202
|
+
* any data that is not yet indexed.
|
|
203
|
+
*
|
|
204
|
+
* Use {@link Table#optimize} to index all un-indexed data.
|
|
205
|
+
*/
|
|
206
|
+
fastSearch(): this;
|
|
207
|
+
}
|
|
200
208
|
/**
|
|
201
209
|
* An interface for a query that can be executed
|
|
202
210
|
*
|
|
@@ -213,7 +221,7 @@ export interface ExecutableQuery {
|
|
|
213
221
|
*
|
|
214
222
|
* @hideconstructor
|
|
215
223
|
*/
|
|
216
|
-
export declare class VectorQuery extends
|
|
224
|
+
export declare class VectorQuery extends StandardQueryBase<NativeVectorQuery> {
|
|
217
225
|
/**
|
|
218
226
|
* @hidden
|
|
219
227
|
*/
|
|
@@ -364,13 +372,21 @@ export declare class VectorQuery extends QueryBase<NativeVectorQuery> {
|
|
|
364
372
|
addQueryVector(vector: IntoVector): VectorQuery;
|
|
365
373
|
rerank(reranker: Reranker): VectorQuery;
|
|
366
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* A query that returns a subset of the rows in the table.
|
|
377
|
+
*
|
|
378
|
+
* @hideconstructor
|
|
379
|
+
*/
|
|
380
|
+
export declare class TakeQuery extends QueryBase<NativeTakeQuery> {
|
|
381
|
+
constructor(inner: NativeTakeQuery);
|
|
382
|
+
}
|
|
367
383
|
/** A builder for LanceDB queries.
|
|
368
384
|
*
|
|
369
385
|
* @see {@link Table#query}, {@link Table#search}
|
|
370
386
|
*
|
|
371
387
|
* @hideconstructor
|
|
372
388
|
*/
|
|
373
|
-
export declare class Query extends
|
|
389
|
+
export declare class Query extends StandardQueryBase<NativeQuery> {
|
|
374
390
|
/**
|
|
375
391
|
* @hidden
|
|
376
392
|
*/
|
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.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.Query = exports.VectorQuery = exports.QueryBase = exports.RecordBatchIterator = void 0;
|
|
5
|
+
exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.Query = exports.TakeQuery = exports.VectorQuery = exports.StandardQueryBase = exports.QueryBase = exports.RecordBatchIterator = void 0;
|
|
6
6
|
exports.instanceOfFullTextQuery = instanceOfFullTextQuery;
|
|
7
7
|
const arrow_1 = require("./arrow");
|
|
8
8
|
const native_1 = require("./native");
|
|
@@ -77,53 +77,6 @@ class QueryBase {
|
|
|
77
77
|
fn(this.inner);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
/**
|
|
81
|
-
* A filter statement to be applied to this query.
|
|
82
|
-
*
|
|
83
|
-
* The filter should be supplied as an SQL query string. For example:
|
|
84
|
-
* @example
|
|
85
|
-
* x > 10
|
|
86
|
-
* y > 0 AND y < 100
|
|
87
|
-
* x > 5 OR y = 'test'
|
|
88
|
-
*
|
|
89
|
-
* Filtering performance can often be improved by creating a scalar index
|
|
90
|
-
* on the filter column(s).
|
|
91
|
-
*/
|
|
92
|
-
where(predicate) {
|
|
93
|
-
this.doCall((inner) => inner.onlyIf(predicate));
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* A filter statement to be applied to this query.
|
|
98
|
-
* @see where
|
|
99
|
-
* @deprecated Use `where` instead
|
|
100
|
-
*/
|
|
101
|
-
filter(predicate) {
|
|
102
|
-
return this.where(predicate);
|
|
103
|
-
}
|
|
104
|
-
fullTextSearch(query, options) {
|
|
105
|
-
let columns = null;
|
|
106
|
-
if (options) {
|
|
107
|
-
if (typeof options.columns === "string") {
|
|
108
|
-
columns = [options.columns];
|
|
109
|
-
}
|
|
110
|
-
else if (Array.isArray(options.columns)) {
|
|
111
|
-
columns = options.columns;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
this.doCall((inner) => {
|
|
115
|
-
if (typeof query === "string") {
|
|
116
|
-
inner.fullTextSearch({
|
|
117
|
-
query: query,
|
|
118
|
-
columns: columns,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
inner.fullTextSearch({ query: query.inner });
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
80
|
/**
|
|
128
81
|
* Return only the specified columns.
|
|
129
82
|
*
|
|
@@ -179,30 +132,6 @@ class QueryBase {
|
|
|
179
132
|
}
|
|
180
133
|
return this;
|
|
181
134
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Set the maximum number of results to return.
|
|
184
|
-
*
|
|
185
|
-
* By default, a plain search has no limit. If this method is not
|
|
186
|
-
* called then every valid row from the table will be returned.
|
|
187
|
-
*/
|
|
188
|
-
limit(limit) {
|
|
189
|
-
this.doCall((inner) => inner.limit(limit));
|
|
190
|
-
return this;
|
|
191
|
-
}
|
|
192
|
-
offset(offset) {
|
|
193
|
-
this.doCall((inner) => inner.offset(offset));
|
|
194
|
-
return this;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Skip searching un-indexed data. This can make search faster, but will miss
|
|
198
|
-
* any data that is not yet indexed.
|
|
199
|
-
*
|
|
200
|
-
* Use {@link Table#optimize} to index all un-indexed data.
|
|
201
|
-
*/
|
|
202
|
-
fastSearch() {
|
|
203
|
-
this.doCall((inner) => inner.fastSearch());
|
|
204
|
-
return this;
|
|
205
|
-
}
|
|
206
135
|
/**
|
|
207
136
|
* Whether to return the row id in the results.
|
|
208
137
|
*
|
|
@@ -329,6 +258,88 @@ class QueryBase {
|
|
|
329
258
|
}
|
|
330
259
|
}
|
|
331
260
|
exports.QueryBase = QueryBase;
|
|
261
|
+
class StandardQueryBase extends QueryBase {
|
|
262
|
+
constructor(inner) {
|
|
263
|
+
super(inner);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* A filter statement to be applied to this query.
|
|
267
|
+
*
|
|
268
|
+
* The filter should be supplied as an SQL query string. For example:
|
|
269
|
+
* @example
|
|
270
|
+
* x > 10
|
|
271
|
+
* y > 0 AND y < 100
|
|
272
|
+
* x > 5 OR y = 'test'
|
|
273
|
+
*
|
|
274
|
+
* Filtering performance can often be improved by creating a scalar index
|
|
275
|
+
* on the filter column(s).
|
|
276
|
+
*/
|
|
277
|
+
where(predicate) {
|
|
278
|
+
this.doCall((inner) => inner.onlyIf(predicate));
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* A filter statement to be applied to this query.
|
|
283
|
+
* @see where
|
|
284
|
+
* @deprecated Use `where` instead
|
|
285
|
+
*/
|
|
286
|
+
filter(predicate) {
|
|
287
|
+
return this.where(predicate);
|
|
288
|
+
}
|
|
289
|
+
fullTextSearch(query, options) {
|
|
290
|
+
let columns = null;
|
|
291
|
+
if (options) {
|
|
292
|
+
if (typeof options.columns === "string") {
|
|
293
|
+
columns = [options.columns];
|
|
294
|
+
}
|
|
295
|
+
else if (Array.isArray(options.columns)) {
|
|
296
|
+
columns = options.columns;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
this.doCall((inner) => {
|
|
300
|
+
if (typeof query === "string") {
|
|
301
|
+
inner.fullTextSearch({
|
|
302
|
+
query: query,
|
|
303
|
+
columns: columns,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
inner.fullTextSearch({ query: query.inner });
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
return this;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Set the maximum number of results to return.
|
|
314
|
+
*
|
|
315
|
+
* By default, a plain search has no limit. If this method is not
|
|
316
|
+
* called then every valid row from the table will be returned.
|
|
317
|
+
*/
|
|
318
|
+
limit(limit) {
|
|
319
|
+
this.doCall((inner) => inner.limit(limit));
|
|
320
|
+
return this;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Set the number of rows to skip before returning results.
|
|
324
|
+
*
|
|
325
|
+
* This is useful for pagination.
|
|
326
|
+
*/
|
|
327
|
+
offset(offset) {
|
|
328
|
+
this.doCall((inner) => inner.offset(offset));
|
|
329
|
+
return this;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Skip searching un-indexed data. This can make search faster, but will miss
|
|
333
|
+
* any data that is not yet indexed.
|
|
334
|
+
*
|
|
335
|
+
* Use {@link Table#optimize} to index all un-indexed data.
|
|
336
|
+
*/
|
|
337
|
+
fastSearch() {
|
|
338
|
+
this.doCall((inner) => inner.fastSearch());
|
|
339
|
+
return this;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
exports.StandardQueryBase = StandardQueryBase;
|
|
332
343
|
/**
|
|
333
344
|
* A builder used to construct a vector search
|
|
334
345
|
*
|
|
@@ -338,7 +349,7 @@ exports.QueryBase = QueryBase;
|
|
|
338
349
|
*
|
|
339
350
|
* @hideconstructor
|
|
340
351
|
*/
|
|
341
|
-
class VectorQuery extends
|
|
352
|
+
class VectorQuery extends StandardQueryBase {
|
|
342
353
|
/**
|
|
343
354
|
* @hidden
|
|
344
355
|
*/
|
|
@@ -575,13 +586,24 @@ class VectorQuery extends QueryBase {
|
|
|
575
586
|
}
|
|
576
587
|
}
|
|
577
588
|
exports.VectorQuery = VectorQuery;
|
|
589
|
+
/**
|
|
590
|
+
* A query that returns a subset of the rows in the table.
|
|
591
|
+
*
|
|
592
|
+
* @hideconstructor
|
|
593
|
+
*/
|
|
594
|
+
class TakeQuery extends QueryBase {
|
|
595
|
+
constructor(inner) {
|
|
596
|
+
super(inner);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
exports.TakeQuery = TakeQuery;
|
|
578
600
|
/** A builder for LanceDB queries.
|
|
579
601
|
*
|
|
580
602
|
* @see {@link Table#query}, {@link Table#search}
|
|
581
603
|
*
|
|
582
604
|
* @hideconstructor
|
|
583
605
|
*/
|
|
584
|
-
class Query extends
|
|
606
|
+
class Query extends StandardQueryBase {
|
|
585
607
|
/**
|
|
586
608
|
* @hidden
|
|
587
609
|
*/
|
package/dist/table.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Table as ArrowTable, Data, DataType, IntoVector, MultiVector, Schema }
|
|
|
2
2
|
import { IndexOptions } from "./indices";
|
|
3
3
|
import { MergeInsertBuilder } from "./merge";
|
|
4
4
|
import { AddColumnsResult, AddColumnsSql, AddResult, AlterColumnsResult, DeleteResult, DropColumnsResult, IndexConfig, IndexStatistics, OptimizeStats, TableStatistics, Tags, UpdateResult, Table as _NativeTable } from "./native";
|
|
5
|
-
import { FullTextQuery, Query, VectorQuery } from "./query";
|
|
5
|
+
import { FullTextQuery, Query, TakeQuery, VectorQuery } from "./query";
|
|
6
6
|
import { IntoSql } from "./util";
|
|
7
7
|
export { IndexConfig } from "./native";
|
|
8
8
|
/**
|
|
@@ -269,6 +269,18 @@ export declare abstract class Table {
|
|
|
269
269
|
* @returns {Query} A builder that can be used to parameterize the query
|
|
270
270
|
*/
|
|
271
271
|
abstract query(): Query;
|
|
272
|
+
/**
|
|
273
|
+
* Create a query that returns a subset of the rows in the table.
|
|
274
|
+
* @param offsets The offsets of the rows to return.
|
|
275
|
+
* @returns A builder that can be used to parameterize the query.
|
|
276
|
+
*/
|
|
277
|
+
abstract takeOffsets(offsets: number[]): TakeQuery;
|
|
278
|
+
/**
|
|
279
|
+
* Create a query that returns a subset of the rows in the table.
|
|
280
|
+
* @param rowIds The row ids of the rows to return.
|
|
281
|
+
* @returns A builder that can be used to parameterize the query.
|
|
282
|
+
*/
|
|
283
|
+
abstract takeRowIds(rowIds: number[]): TakeQuery;
|
|
272
284
|
/**
|
|
273
285
|
* Create a search query to find the nearest neighbors
|
|
274
286
|
* of the given query
|
|
@@ -462,6 +474,8 @@ export declare class LocalTable extends Table {
|
|
|
462
474
|
dropIndex(name: string): Promise<void>;
|
|
463
475
|
prewarmIndex(name: string): Promise<void>;
|
|
464
476
|
waitForIndex(indexNames: string[], timeoutSeconds: number): Promise<void>;
|
|
477
|
+
takeOffsets(offsets: number[]): TakeQuery;
|
|
478
|
+
takeRowIds(rowIds: number[]): TakeQuery;
|
|
465
479
|
query(): Query;
|
|
466
480
|
search(query: string | IntoVector | MultiVector | FullTextQuery, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query;
|
|
467
481
|
vectorSearch(vector: IntoVector | MultiVector): VectorQuery;
|
package/dist/table.js
CHANGED
|
@@ -134,6 +134,12 @@ class LocalTable extends Table {
|
|
|
134
134
|
async waitForIndex(indexNames, timeoutSeconds) {
|
|
135
135
|
await this.inner.waitForIndex(indexNames, timeoutSeconds);
|
|
136
136
|
}
|
|
137
|
+
takeOffsets(offsets) {
|
|
138
|
+
return new query_1.TakeQuery(this.inner.takeOffsets(offsets));
|
|
139
|
+
}
|
|
140
|
+
takeRowIds(rowIds) {
|
|
141
|
+
return new query_1.TakeQuery(this.inner.takeRowIds(rowIds));
|
|
142
|
+
}
|
|
137
143
|
query() {
|
|
138
144
|
return new query_1.Query(this.inner);
|
|
139
145
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"ann"
|
|
12
12
|
],
|
|
13
13
|
"private": false,
|
|
14
|
-
"version": "0.21.
|
|
14
|
+
"version": "0.21.3",
|
|
15
15
|
"main": "dist/index.js",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
]
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
"license": "Apache
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@aws-sdk/client-dynamodb": "^3.33.0",
|
|
42
42
|
"@aws-sdk/client-kms": "^3.33.0",
|
|
@@ -100,14 +100,14 @@
|
|
|
100
100
|
"reflect-metadata": "^0.2.2"
|
|
101
101
|
},
|
|
102
102
|
"optionalDependencies": {
|
|
103
|
-
"@lancedb/lancedb-darwin-x64": "0.21.
|
|
104
|
-
"@lancedb/lancedb-darwin-arm64": "0.21.
|
|
105
|
-
"@lancedb/lancedb-linux-x64-gnu": "0.21.
|
|
106
|
-
"@lancedb/lancedb-linux-arm64-gnu": "0.21.
|
|
107
|
-
"@lancedb/lancedb-linux-x64-musl": "0.21.
|
|
108
|
-
"@lancedb/lancedb-linux-arm64-musl": "0.21.
|
|
109
|
-
"@lancedb/lancedb-win32-x64-msvc": "0.21.
|
|
110
|
-
"@lancedb/lancedb-win32-arm64-msvc": "0.21.
|
|
103
|
+
"@lancedb/lancedb-darwin-x64": "0.21.3",
|
|
104
|
+
"@lancedb/lancedb-darwin-arm64": "0.21.3",
|
|
105
|
+
"@lancedb/lancedb-linux-x64-gnu": "0.21.3",
|
|
106
|
+
"@lancedb/lancedb-linux-arm64-gnu": "0.21.3",
|
|
107
|
+
"@lancedb/lancedb-linux-x64-musl": "0.21.3",
|
|
108
|
+
"@lancedb/lancedb-linux-arm64-musl": "0.21.3",
|
|
109
|
+
"@lancedb/lancedb-win32-x64-msvc": "0.21.3",
|
|
110
|
+
"@lancedb/lancedb-win32-arm64-msvc": "0.21.3"
|
|
111
111
|
},
|
|
112
112
|
"peerDependencies": {
|
|
113
113
|
"apache-arrow": ">=15.0.0 <=18.1.0"
|