@lancedb/lancedb 0.19.0-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 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
@@ -283,7 +283,7 @@ export class NativeMergeInsertBuilder {
283
283
  }
284
284
  export class Query {
285
285
  onlyIf(predicate: string): void
286
- fullTextSearch(query: string, columns?: Array<string> | undefined | null): void
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
@@ -306,7 +306,7 @@ export class VectorQuery {
306
306
  ef(ef: number): void
307
307
  bypassVectorIndex(): void
308
308
  onlyIf(predicate: string): void
309
- fullTextSearch(query: string, columns?: Array<string> | undefined | null): void
309
+ fullTextSearch(query: unknown): void
310
310
  select(columns: Array<[string, string]>): void
311
311
  selectColumns(columns: Array<string>): void
312
312
  limit(limit: number): void
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
  *
@@ -386,5 +386,93 @@ export declare class Query extends QueryBase<NativeQuery> {
386
386
  * a default `limit` of 10 will be used. @see {@link Query#limit}
387
387
  */
388
388
  nearestTo(vector: IntoVector): VectorQuery;
389
- 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>;
390
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) => inner.fullTextSearch(query, columns));
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
  /**
@@ -620,8 +632,163 @@ class Query extends QueryBase {
620
632
  }
621
633
  }
622
634
  nearestToText(query, columns) {
623
- this.doCall((inner) => inner.fullTextSearch(query, columns));
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
+ });
624
647
  return this;
625
648
  }
626
649
  }
627
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.19.0-beta.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.19.0-beta.0",
103
- "@lancedb/lancedb-darwin-arm64": "0.19.0-beta.0",
104
- "@lancedb/lancedb-linux-x64-gnu": "0.19.0-beta.0",
105
- "@lancedb/lancedb-linux-arm64-gnu": "0.19.0-beta.0",
106
- "@lancedb/lancedb-linux-arm64-musl": "0.19.0-beta.0",
107
- "@lancedb/lancedb-win32-x64-msvc": "0.19.0-beta.0",
108
- "@lancedb/lancedb-win32-arm64-msvc": "0.19.0-beta.0"
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"