@lancedb/lancedb 0.20.0 → 0.20.1-beta.0

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 CHANGED
@@ -3,7 +3,7 @@ import { ConnectionOptions } from "./native.js";
3
3
  export { AddColumnsSql, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, MergeResult, AddResult, AddColumnsResult, AlterColumnsResult, DeleteResult, DropColumnsResult, UpdateResult, } 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, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, FullTextQueryType, } from "./query";
6
+ export { ExecutableQuery, Query, QueryBase, VectorQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, BooleanQuery, FullTextQueryType, Operator, Occur, } 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, 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.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 = 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.VectorQuery = exports.QueryBase = exports.Query = 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");
@@ -24,7 +24,10 @@ Object.defineProperty(exports, "MatchQuery", { enumerable: true, get: function (
24
24
  Object.defineProperty(exports, "PhraseQuery", { enumerable: true, get: function () { return query_1.PhraseQuery; } });
25
25
  Object.defineProperty(exports, "BoostQuery", { enumerable: true, get: function () { return query_1.BoostQuery; } });
26
26
  Object.defineProperty(exports, "MultiMatchQuery", { enumerable: true, get: function () { return query_1.MultiMatchQuery; } });
27
+ Object.defineProperty(exports, "BooleanQuery", { enumerable: true, get: function () { return query_1.BooleanQuery; } });
27
28
  Object.defineProperty(exports, "FullTextQueryType", { enumerable: true, get: function () { return query_1.FullTextQueryType; } });
29
+ Object.defineProperty(exports, "Operator", { enumerable: true, get: function () { return query_1.Operator; } });
30
+ Object.defineProperty(exports, "Occur", { enumerable: true, get: function () { return query_1.Occur; } });
28
31
  var indices_1 = require("./indices");
29
32
  Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return indices_1.Index; } });
30
33
  var table_1 = require("./table");
package/dist/native.d.ts CHANGED
@@ -362,6 +362,8 @@ export class VectorQuery {
362
362
  postfilter(): void
363
363
  refineFactor(refineFactor: number): void
364
364
  nprobes(nprobe: number): void
365
+ minimumNprobes(minimumNprobe: number): void
366
+ maximumNprobes(maximumNprobes: number): void
365
367
  distanceRange(lowerBound?: number | undefined | null, upperBound?: number | undefined | null): void
366
368
  ef(ef: number): void
367
369
  bypassVectorIndex(): void
@@ -379,10 +381,12 @@ export class VectorQuery {
379
381
  analyzePlan(): Promise<string>
380
382
  }
381
383
  export class JsFullTextQuery {
382
- static matchQuery(query: string, column: string, boost: number, fuzziness: number | undefined | null, maxExpansions: number): JsFullTextQuery
383
- static phraseQuery(query: string, column: string): JsFullTextQuery
384
+ static matchQuery(query: string, column: string, boost: number, fuzziness: number | undefined | null, maxExpansions: number, operator: string): JsFullTextQuery
385
+ static phraseQuery(query: string, column: string, slop: number): JsFullTextQuery
384
386
  static boostQuery(positive: JsFullTextQuery, negative: JsFullTextQuery, negativeBoost?: number | undefined | null): JsFullTextQuery
385
- static multiMatchQuery(query: string, columns: Array<string>, boosts?: Array<number> | undefined | null): JsFullTextQuery
387
+ static multiMatchQuery(query: string, columns: Array<string>, boosts: Array<number> | undefined | null, operator: string): JsFullTextQuery
388
+ static booleanQuery(queries: Array<[string, JsFullTextQuery]>): JsFullTextQuery
389
+ get queryType(): string
386
390
  }
387
391
  /**
388
392
  * Reranker implementation that "wraps" a NodeJS Reranker implementation.
package/dist/query.d.ts CHANGED
@@ -239,8 +239,31 @@ export declare class VectorQuery extends QueryBase<NativeVectorQuery> {
239
239
  * For best results we recommend tuning this parameter with a benchmark against
240
240
  * your actual data to find the smallest possible value that will still give
241
241
  * you the desired recall.
242
+ *
243
+ * For more fine grained control over behavior when you have a very narrow filter
244
+ * you can use `minimumNprobes` and `maximumNprobes`. This method sets both
245
+ * the minimum and maximum to the same value.
242
246
  */
243
247
  nprobes(nprobes: number): VectorQuery;
248
+ /**
249
+ * Set the minimum number of probes used.
250
+ *
251
+ * This controls the minimum number of partitions that will be searched. This
252
+ * parameter will impact every query against a vector index, regardless of the
253
+ * filter. See `nprobes` for more details. Higher values will increase recall
254
+ * but will also increase latency.
255
+ */
256
+ minimumNprobes(minimumNprobes: number): VectorQuery;
257
+ /**
258
+ * Set the maximum number of probes used.
259
+ *
260
+ * This controls the maximum number of partitions that will be searched. If this
261
+ * number is greater than minimumNprobes then the excess partitions will _only_ be
262
+ * searched if we have not found enough results. This can be useful when there is
263
+ * a narrow filter to allow these queries to spend more time searching and avoid
264
+ * potential false negatives.
265
+ */
266
+ maximumNprobes(maximumNprobes: number): VectorQuery;
244
267
  distanceRange(lowerBound?: number, upperBound?: number): VectorQuery;
245
268
  /**
246
269
  * Set the number of candidates to consider during the search
@@ -404,7 +427,28 @@ export declare enum FullTextQueryType {
404
427
  Match = "match",
405
428
  MatchPhrase = "match_phrase",
406
429
  Boost = "boost",
407
- MultiMatch = "multi_match"
430
+ MultiMatch = "multi_match",
431
+ Boolean = "boolean"
432
+ }
433
+ /**
434
+ * Enum representing the logical operators used in full-text queries.
435
+ *
436
+ * - `And`: All terms must match.
437
+ * - `Or`: At least one term must match.
438
+ */
439
+ export declare enum Operator {
440
+ And = "AND",
441
+ Or = "OR"
442
+ }
443
+ /**
444
+ * Enum representing the occurrence of terms in full-text queries.
445
+ *
446
+ * - `Must`: The term must be present in the document.
447
+ * - `Should`: The term should contribute to the document score, but is not required.
448
+ */
449
+ export declare enum Occur {
450
+ Must = "MUST",
451
+ Should = "SHOULD"
408
452
  }
409
453
  /**
410
454
  * Represents a full-text query interface.
@@ -436,11 +480,13 @@ export declare class MatchQuery implements FullTextQuery {
436
480
  * - `boost`: The boost factor for the query (default is 1.0).
437
481
  * - `fuzziness`: The fuzziness level for the query (default is 0).
438
482
  * - `maxExpansions`: The maximum number of terms to consider for fuzzy matching (default is 50).
483
+ * - `operator`: The logical operator to use for combining terms in the query (default is "OR").
439
484
  */
440
485
  constructor(query: string, column: string, options?: {
441
486
  boost?: number;
442
487
  fuzziness?: number;
443
488
  maxExpansions?: number;
489
+ operator?: Operator;
444
490
  });
445
491
  queryType(): FullTextQueryType;
446
492
  }
@@ -452,8 +498,12 @@ export declare class PhraseQuery implements FullTextQuery {
452
498
  *
453
499
  * @param query - The phrase to search for in the specified column.
454
500
  * @param column - The name of the column to search within.
501
+ * @param options - Optional parameters for the phrase query.
502
+ * - `slop`: The maximum number of intervening unmatched positions allowed between words in the phrase (default is 0).
455
503
  */
456
- constructor(query: string, column: string);
504
+ constructor(query: string, column: string, options?: {
505
+ slop?: number;
506
+ });
457
507
  queryType(): FullTextQueryType;
458
508
  }
459
509
  export declare class BoostQuery implements FullTextQuery {
@@ -485,9 +535,23 @@ export declare class MultiMatchQuery implements FullTextQuery {
485
535
  * @param columns - An array of column names to search within.
486
536
  * @param options - Optional parameters for the multi-match query.
487
537
  * - `boosts`: An array of boost factors for each column (default is 1.0 for all).
538
+ * - `operator`: The logical operator to use for combining terms in the query (default is "OR").
488
539
  */
489
540
  constructor(query: string, columns: string[], options?: {
490
541
  boosts?: number[];
542
+ operator?: Operator;
491
543
  });
492
544
  queryType(): FullTextQueryType;
493
545
  }
546
+ export declare class BooleanQuery implements FullTextQuery {
547
+ /** @ignore */
548
+ readonly inner: JsFullTextQuery;
549
+ /**
550
+ * Creates an instance of BooleanQuery.
551
+ *
552
+ * @param queries - An array of (Occur, FullTextQuery objects) to combine.
553
+ * Occur specifies whether the query must match, or should match.
554
+ */
555
+ constructor(queries: [Occur, FullTextQuery][]);
556
+ queryType(): FullTextQueryType;
557
+ }
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.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = 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.VectorQuery = 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");
@@ -366,11 +366,40 @@ class VectorQuery extends QueryBase {
366
366
  * For best results we recommend tuning this parameter with a benchmark against
367
367
  * your actual data to find the smallest possible value that will still give
368
368
  * you the desired recall.
369
+ *
370
+ * For more fine grained control over behavior when you have a very narrow filter
371
+ * you can use `minimumNprobes` and `maximumNprobes`. This method sets both
372
+ * the minimum and maximum to the same value.
369
373
  */
370
374
  nprobes(nprobes) {
371
375
  super.doCall((inner) => inner.nprobes(nprobes));
372
376
  return this;
373
377
  }
378
+ /**
379
+ * Set the minimum number of probes used.
380
+ *
381
+ * This controls the minimum number of partitions that will be searched. This
382
+ * parameter will impact every query against a vector index, regardless of the
383
+ * filter. See `nprobes` for more details. Higher values will increase recall
384
+ * but will also increase latency.
385
+ */
386
+ minimumNprobes(minimumNprobes) {
387
+ super.doCall((inner) => inner.minimumNprobes(minimumNprobes));
388
+ return this;
389
+ }
390
+ /**
391
+ * Set the maximum number of probes used.
392
+ *
393
+ * This controls the maximum number of partitions that will be searched. If this
394
+ * number is greater than minimumNprobes then the excess partitions will _only_ be
395
+ * searched if we have not found enough results. This can be useful when there is
396
+ * a narrow filter to allow these queries to spend more time searching and avoid
397
+ * potential false negatives.
398
+ */
399
+ maximumNprobes(maximumNprobes) {
400
+ super.doCall((inner) => inner.maximumNprobes(maximumNprobes));
401
+ return this;
402
+ }
374
403
  /*
375
404
  * Set the distance range to use
376
405
  *
@@ -661,7 +690,30 @@ var FullTextQueryType;
661
690
  FullTextQueryType["MatchPhrase"] = "match_phrase";
662
691
  FullTextQueryType["Boost"] = "boost";
663
692
  FullTextQueryType["MultiMatch"] = "multi_match";
693
+ FullTextQueryType["Boolean"] = "boolean";
664
694
  })(FullTextQueryType || (exports.FullTextQueryType = FullTextQueryType = {}));
695
+ /**
696
+ * Enum representing the logical operators used in full-text queries.
697
+ *
698
+ * - `And`: All terms must match.
699
+ * - `Or`: At least one term must match.
700
+ */
701
+ var Operator;
702
+ (function (Operator) {
703
+ Operator["And"] = "AND";
704
+ Operator["Or"] = "OR";
705
+ })(Operator || (exports.Operator = Operator = {}));
706
+ /**
707
+ * Enum representing the occurrence of terms in full-text queries.
708
+ *
709
+ * - `Must`: The term must be present in the document.
710
+ * - `Should`: The term should contribute to the document score, but is not required.
711
+ */
712
+ var Occur;
713
+ (function (Occur) {
714
+ Occur["Must"] = "MUST";
715
+ Occur["Should"] = "SHOULD";
716
+ })(Occur || (exports.Occur = Occur = {}));
665
717
  // biome-ignore lint/suspicious/noExplicitAny: we want any here
666
718
  function instanceOfFullTextQuery(obj) {
667
719
  return obj != null && obj.inner instanceof native_1.JsFullTextQuery;
@@ -678,13 +730,14 @@ class MatchQuery {
678
730
  * - `boost`: The boost factor for the query (default is 1.0).
679
731
  * - `fuzziness`: The fuzziness level for the query (default is 0).
680
732
  * - `maxExpansions`: The maximum number of terms to consider for fuzzy matching (default is 50).
733
+ * - `operator`: The logical operator to use for combining terms in the query (default is "OR").
681
734
  */
682
735
  constructor(query, column, options) {
683
736
  let fuzziness = options?.fuzziness;
684
737
  if (fuzziness === undefined) {
685
738
  fuzziness = 0;
686
739
  }
687
- this.inner = native_1.JsFullTextQuery.matchQuery(query, column, options?.boost ?? 1.0, fuzziness, options?.maxExpansions ?? 50);
740
+ this.inner = native_1.JsFullTextQuery.matchQuery(query, column, options?.boost ?? 1.0, fuzziness, options?.maxExpansions ?? 50, options?.operator ?? Operator.Or);
688
741
  }
689
742
  queryType() {
690
743
  return FullTextQueryType.Match;
@@ -699,9 +752,11 @@ class PhraseQuery {
699
752
  *
700
753
  * @param query - The phrase to search for in the specified column.
701
754
  * @param column - The name of the column to search within.
755
+ * @param options - Optional parameters for the phrase query.
756
+ * - `slop`: The maximum number of intervening unmatched positions allowed between words in the phrase (default is 0).
702
757
  */
703
- constructor(query, column) {
704
- this.inner = native_1.JsFullTextQuery.phraseQuery(query, column);
758
+ constructor(query, column, options) {
759
+ this.inner = native_1.JsFullTextQuery.phraseQuery(query, column, options?.slop ?? 0);
705
760
  }
706
761
  queryType() {
707
762
  return FullTextQueryType.MatchPhrase;
@@ -740,12 +795,30 @@ class MultiMatchQuery {
740
795
  * @param columns - An array of column names to search within.
741
796
  * @param options - Optional parameters for the multi-match query.
742
797
  * - `boosts`: An array of boost factors for each column (default is 1.0 for all).
798
+ * - `operator`: The logical operator to use for combining terms in the query (default is "OR").
743
799
  */
744
800
  constructor(query, columns, options) {
745
- this.inner = native_1.JsFullTextQuery.multiMatchQuery(query, columns, options?.boosts);
801
+ this.inner = native_1.JsFullTextQuery.multiMatchQuery(query, columns, options?.boosts, options?.operator ?? Operator.Or);
746
802
  }
747
803
  queryType() {
748
804
  return FullTextQueryType.MultiMatch;
749
805
  }
750
806
  }
751
807
  exports.MultiMatchQuery = MultiMatchQuery;
808
+ class BooleanQuery {
809
+ /** @ignore */
810
+ inner;
811
+ /**
812
+ * Creates an instance of BooleanQuery.
813
+ *
814
+ * @param queries - An array of (Occur, FullTextQuery objects) to combine.
815
+ * Occur specifies whether the query must match, or should match.
816
+ */
817
+ constructor(queries) {
818
+ this.inner = native_1.JsFullTextQuery.booleanQuery(queries.map(([occur, query]) => [occur, query.inner]));
819
+ }
820
+ queryType() {
821
+ return FullTextQueryType.Boolean;
822
+ }
823
+ }
824
+ exports.BooleanQuery = BooleanQuery;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ann"
12
12
  ],
13
13
  "private": false,
14
- "version": "0.20.0",
14
+ "version": "0.20.1-beta.0",
15
15
  "main": "dist/index.js",
16
16
  "exports": {
17
17
  ".": "./dist/index.js",
@@ -100,14 +100,14 @@
100
100
  "reflect-metadata": "^0.2.2"
101
101
  },
102
102
  "optionalDependencies": {
103
- "@lancedb/lancedb-darwin-x64": "0.20.0",
104
- "@lancedb/lancedb-darwin-arm64": "0.20.0",
105
- "@lancedb/lancedb-linux-x64-gnu": "0.20.0",
106
- "@lancedb/lancedb-linux-arm64-gnu": "0.20.0",
107
- "@lancedb/lancedb-linux-x64-musl": "0.20.0",
108
- "@lancedb/lancedb-linux-arm64-musl": "0.20.0",
109
- "@lancedb/lancedb-win32-x64-msvc": "0.20.0",
110
- "@lancedb/lancedb-win32-arm64-msvc": "0.20.0"
103
+ "@lancedb/lancedb-darwin-x64": "0.20.1-beta.0",
104
+ "@lancedb/lancedb-darwin-arm64": "0.20.1-beta.0",
105
+ "@lancedb/lancedb-linux-x64-gnu": "0.20.1-beta.0",
106
+ "@lancedb/lancedb-linux-arm64-gnu": "0.20.1-beta.0",
107
+ "@lancedb/lancedb-linux-x64-musl": "0.20.1-beta.0",
108
+ "@lancedb/lancedb-linux-arm64-musl": "0.20.1-beta.0",
109
+ "@lancedb/lancedb-win32-x64-msvc": "0.20.1-beta.0",
110
+ "@lancedb/lancedb-win32-arm64-msvc": "0.20.1-beta.0"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "apache-arrow": ">=15.0.0 <=18.1.0"