@lancedb/lancedb
Advanced tools
Comparing version 0.9.0 to 0.10.0-beta.0
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Table as ArrowTable, Binary, BufferType, Field, FixedSizeBinary, FixedSizeList, Float, Int, LargeBinary, List, Null, RecordBatch, Schema, Struct, Utf8 } from "apache-arrow"; | ||
@@ -3,0 +2,0 @@ import { Buffers } from "apache-arrow/data"; |
@@ -30,3 +30,33 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createEmptyTable = exports.fromTableToStreamBuffer = exports.fromDataToBuffer = exports.fromTableToBuffer = exports.fromRecordsToStreamBuffer = exports.fromRecordsToBuffer = exports.newVectorType = exports.convertToTable = exports.makeEmptyTable = exports.makeArrowTable = exports.MakeArrowTableOptions = exports.VectorColumnOptions = exports.isFixedSizeList = exports.isFixedSizeBinary = exports.isUnion = exports.isStruct = exports.isList = exports.isDuration = exports.isInterval = exports.isTimestamp = exports.isTime = exports.isDate = exports.isDecimal = exports.isBool = exports.isLargeUtf8 = exports.isUtf8 = exports.isLargeBinary = exports.isBinary = exports.isFloat = exports.isInt = exports.isNull = exports.isArrowTable = void 0; | ||
exports.MakeArrowTableOptions = exports.VectorColumnOptions = void 0; | ||
exports.isArrowTable = isArrowTable; | ||
exports.isNull = isNull; | ||
exports.isInt = isInt; | ||
exports.isFloat = isFloat; | ||
exports.isBinary = isBinary; | ||
exports.isLargeBinary = isLargeBinary; | ||
exports.isUtf8 = isUtf8; | ||
exports.isLargeUtf8 = isLargeUtf8; | ||
exports.isBool = isBool; | ||
exports.isDecimal = isDecimal; | ||
exports.isDate = isDate; | ||
exports.isTime = isTime; | ||
exports.isTimestamp = isTimestamp; | ||
exports.isInterval = isInterval; | ||
exports.isDuration = isDuration; | ||
exports.isList = isList; | ||
exports.isStruct = isStruct; | ||
exports.isUnion = isUnion; | ||
exports.isFixedSizeBinary = isFixedSizeBinary; | ||
exports.isFixedSizeList = isFixedSizeList; | ||
exports.makeArrowTable = makeArrowTable; | ||
exports.makeEmptyTable = makeEmptyTable; | ||
exports.convertToTable = convertToTable; | ||
exports.newVectorType = newVectorType; | ||
exports.fromRecordsToBuffer = fromRecordsToBuffer; | ||
exports.fromRecordsToStreamBuffer = fromRecordsToStreamBuffer; | ||
exports.fromTableToBuffer = fromTableToBuffer; | ||
exports.fromDataToBuffer = fromDataToBuffer; | ||
exports.fromTableToStreamBuffer = fromTableToStreamBuffer; | ||
exports.createEmptyTable = createEmptyTable; | ||
const apache_arrow_1 = require("apache-arrow"); | ||
@@ -41,79 +71,59 @@ const registry_1 = require("./embedding/registry"); | ||
} | ||
exports.isArrowTable = isArrowTable; | ||
function isNull(value) { | ||
return value instanceof apache_arrow_1.Null || apache_arrow_1.DataType.isNull(value); | ||
} | ||
exports.isNull = isNull; | ||
function isInt(value) { | ||
return value instanceof apache_arrow_1.Int || apache_arrow_1.DataType.isInt(value); | ||
} | ||
exports.isInt = isInt; | ||
function isFloat(value) { | ||
return value instanceof apache_arrow_1.Float || apache_arrow_1.DataType.isFloat(value); | ||
} | ||
exports.isFloat = isFloat; | ||
function isBinary(value) { | ||
return value instanceof apache_arrow_1.Binary || apache_arrow_1.DataType.isBinary(value); | ||
} | ||
exports.isBinary = isBinary; | ||
function isLargeBinary(value) { | ||
return value instanceof apache_arrow_1.LargeBinary || apache_arrow_1.DataType.isLargeBinary(value); | ||
} | ||
exports.isLargeBinary = isLargeBinary; | ||
function isUtf8(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isUtf8(value); | ||
} | ||
exports.isUtf8 = isUtf8; | ||
function isLargeUtf8(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isLargeUtf8(value); | ||
} | ||
exports.isLargeUtf8 = isLargeUtf8; | ||
function isBool(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isBool(value); | ||
} | ||
exports.isBool = isBool; | ||
function isDecimal(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isDecimal(value); | ||
} | ||
exports.isDecimal = isDecimal; | ||
function isDate(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isDate(value); | ||
} | ||
exports.isDate = isDate; | ||
function isTime(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isTime(value); | ||
} | ||
exports.isTime = isTime; | ||
function isTimestamp(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isTimestamp(value); | ||
} | ||
exports.isTimestamp = isTimestamp; | ||
function isInterval(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isInterval(value); | ||
} | ||
exports.isInterval = isInterval; | ||
function isDuration(value) { | ||
return value instanceof apache_arrow_1.Utf8 || apache_arrow_1.DataType.isDuration(value); | ||
} | ||
exports.isDuration = isDuration; | ||
function isList(value) { | ||
return value instanceof apache_arrow_1.List || apache_arrow_1.DataType.isList(value); | ||
} | ||
exports.isList = isList; | ||
function isStruct(value) { | ||
return value instanceof apache_arrow_1.Struct || apache_arrow_1.DataType.isStruct(value); | ||
} | ||
exports.isStruct = isStruct; | ||
function isUnion(value) { | ||
return value instanceof apache_arrow_1.Struct || apache_arrow_1.DataType.isUnion(value); | ||
} | ||
exports.isUnion = isUnion; | ||
function isFixedSizeBinary(value) { | ||
return value instanceof apache_arrow_1.FixedSizeBinary || apache_arrow_1.DataType.isFixedSizeBinary(value); | ||
} | ||
exports.isFixedSizeBinary = isFixedSizeBinary; | ||
function isFixedSizeList(value) { | ||
return value instanceof apache_arrow_1.FixedSizeList || apache_arrow_1.DataType.isFixedSizeList(value); | ||
} | ||
exports.isFixedSizeList = isFixedSizeList; | ||
/* | ||
@@ -376,3 +386,2 @@ * Options to control how a column should be converted to a vector array | ||
} | ||
exports.makeArrowTable = makeArrowTable; | ||
/** | ||
@@ -384,3 +393,2 @@ * Create an empty Arrow table with the provided schema | ||
} | ||
exports.makeEmptyTable = makeEmptyTable; | ||
/** | ||
@@ -581,3 +589,2 @@ * Helper function to convert Array<Array<any>> to a variable sized list array | ||
} | ||
exports.convertToTable = convertToTable; | ||
/** Creates the Arrow Type for a Vector column with dimension `dim` */ | ||
@@ -590,3 +597,2 @@ function newVectorType(dim, innerType) { | ||
} | ||
exports.newVectorType = newVectorType; | ||
/** | ||
@@ -607,3 +613,2 @@ * Serialize an Array of records into a buffer using the Arrow IPC File serialization | ||
} | ||
exports.fromRecordsToBuffer = fromRecordsToBuffer; | ||
/** | ||
@@ -624,3 +629,2 @@ * Serialize an Array of records into a buffer using the Arrow IPC Stream serialization | ||
} | ||
exports.fromRecordsToStreamBuffer = fromRecordsToStreamBuffer; | ||
/** | ||
@@ -642,3 +646,2 @@ * Serialize an Arrow Table into a buffer using the Arrow IPC File serialization | ||
} | ||
exports.fromTableToBuffer = fromTableToBuffer; | ||
/** | ||
@@ -664,3 +667,2 @@ * Serialize an Arrow Table into a buffer using the Arrow IPC File serialization | ||
} | ||
exports.fromDataToBuffer = fromDataToBuffer; | ||
/** | ||
@@ -679,3 +681,2 @@ * Serialize an Arrow Table into a buffer using the Arrow IPC Stream serialization | ||
} | ||
exports.fromTableToStreamBuffer = fromTableToStreamBuffer; | ||
/** | ||
@@ -714,3 +715,2 @@ * Reorder the columns in `batch` so that they agree with the field order in `schema` | ||
} | ||
exports.createEmptyTable = createEmptyTable; | ||
function validateSchemaEmbeddings(schema, data, embeddings) { | ||
@@ -717,0 +717,0 @@ const fields = []; |
@@ -16,3 +16,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cleanseStorageOptions = exports.LocalConnection = exports.Connection = void 0; | ||
exports.LocalConnection = exports.Connection = void 0; | ||
exports.cleanseStorageOptions = cleanseStorageOptions; | ||
const arrow_1 = require("./arrow"); | ||
@@ -131,3 +132,2 @@ const registry_1 = require("./embedding/registry"); | ||
} | ||
exports.cleanseStorageOptions = cleanseStorageOptions; | ||
/** | ||
@@ -134,0 +134,0 @@ * Convert a string to snake case. It might already be snake case, in which case it is |
@@ -30,3 +30,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LanceSchema = exports.TextEmbeddingFunction = exports.EmbeddingFunction = void 0; | ||
exports.TextEmbeddingFunction = exports.EmbeddingFunction = void 0; | ||
exports.LanceSchema = LanceSchema; | ||
const arrow_1 = require("../arrow"); | ||
@@ -82,3 +83,2 @@ const sanitize_1 = require("../sanitize"); | ||
} | ||
exports.LanceSchema = LanceSchema; | ||
function parseEmbeddingFunctions(embeddingFunctions, key, metadata) { | ||
@@ -85,0 +85,0 @@ if (metadata.has("source_column_for")) { |
@@ -20,2 +20,6 @@ import { type EmbeddingFunction, type EmbeddingFunctionConstructor } from "./embedding_function"; | ||
/** | ||
* Get the number of registered functions | ||
*/ | ||
length(): number; | ||
/** | ||
* Register an embedding function | ||
@@ -22,0 +26,0 @@ * @param name The name of the function |
@@ -16,3 +16,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getRegistry = exports.register = exports.EmbeddingFunctionRegistry = void 0; | ||
exports.EmbeddingFunctionRegistry = void 0; | ||
exports.register = register; | ||
exports.getRegistry = getRegistry; | ||
require("reflect-metadata"); | ||
@@ -28,2 +30,8 @@ /** | ||
/** | ||
* Get the number of registered functions | ||
*/ | ||
length() { | ||
return this.#functions.size; | ||
} | ||
/** | ||
* Register an embedding function | ||
@@ -135,3 +143,2 @@ * @param name The name of the function | ||
} | ||
exports.register = register; | ||
/** | ||
@@ -148,2 +155,1 @@ * Utility function to get the global instance of the registry | ||
} | ||
exports.getRegistry = getRegistry; |
@@ -16,3 +16,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.connect = exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0; | ||
exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0; | ||
exports.connect = connect; | ||
const connection_1 = require("./connection"); | ||
@@ -58,2 +59,1 @@ const native_js_1 = require("./native.js"); | ||
} | ||
exports.connect = connect; |
@@ -141,2 +141,32 @@ /** | ||
static btree(): Index; | ||
/** | ||
* Create a bitmap index. | ||
* | ||
* A `Bitmap` index stores a bitmap for each distinct value in the column for every row. | ||
* | ||
* This index works best for low-cardinality columns, where the number of unique values | ||
* is small (i.e., less than a few hundreds). | ||
*/ | ||
static bitmap(): Index; | ||
/** | ||
* Create a label list index. | ||
* | ||
* LabelList index is a scalar index that can be used on `List<T>` columns to | ||
* support queries with `array_contains_all` and `array_contains_any` | ||
* using an underlying bitmap index. | ||
*/ | ||
static labelList(): Index; | ||
/** | ||
* Create a full text search index | ||
* | ||
* A full text search index is an index on a string column, so that you can conduct full | ||
* text searches on the column. | ||
* | ||
* The results of a full text search are ordered by relevance measured by BM25. | ||
* | ||
* You can combine filters with full text search. | ||
* | ||
* For now, the full text search index only supports English, and doesn't support phrase search. | ||
*/ | ||
static fts(): Index; | ||
} | ||
@@ -143,0 +173,0 @@ export interface IndexOptions { |
@@ -70,3 +70,39 @@ "use strict"; | ||
} | ||
/** | ||
* Create a bitmap index. | ||
* | ||
* A `Bitmap` index stores a bitmap for each distinct value in the column for every row. | ||
* | ||
* This index works best for low-cardinality columns, where the number of unique values | ||
* is small (i.e., less than a few hundreds). | ||
*/ | ||
static bitmap() { | ||
return new Index(native_1.Index.bitmap()); | ||
} | ||
/** | ||
* Create a label list index. | ||
* | ||
* LabelList index is a scalar index that can be used on `List<T>` columns to | ||
* support queries with `array_contains_all` and `array_contains_any` | ||
* using an underlying bitmap index. | ||
*/ | ||
static labelList() { | ||
return new Index(native_1.Index.labelList()); | ||
} | ||
/** | ||
* Create a full text search index | ||
* | ||
* A full text search index is an index on a string column, so that you can conduct full | ||
* text searches on the column. | ||
* | ||
* The results of a full text search are ordered by relevance measured by BM25. | ||
* | ||
* You can combine filters with full text search. | ||
* | ||
* For now, the full text search index only supports English, and doesn't support phrase search. | ||
*/ | ||
static fts() { | ||
return new Index(native_1.Index.fts()); | ||
} | ||
} | ||
exports.Index = Index; |
@@ -22,2 +22,14 @@ import { Table as ArrowTable, type IntoVector, RecordBatch } from "./arrow"; | ||
} | ||
/** | ||
* Options that control the behavior of a full text search | ||
*/ | ||
export interface FullTextSearchOptions { | ||
/** | ||
* The columns to search | ||
* | ||
* If not specified, all indexed columns will be searched. | ||
* For now, only one column can be searched. | ||
*/ | ||
columns?: string | string[]; | ||
} | ||
/** Common methods supported by all query types */ | ||
@@ -47,2 +59,3 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVectorQuery> implements AsyncIterable<RecordBatch> { | ||
filter(predicate: string): this; | ||
fullTextSearch(query: string, options?: Partial<FullTextSearchOptions>): this; | ||
/** | ||
@@ -49,0 +62,0 @@ * Return only the specified columns. |
@@ -101,2 +101,15 @@ "use strict"; | ||
} | ||
fullTextSearch(query, options) { | ||
let columns = null; | ||
if (options) { | ||
if (typeof options.columns === "string") { | ||
columns = [options.columns]; | ||
} | ||
else if (Array.isArray(options.columns)) { | ||
columns = options.columns; | ||
} | ||
} | ||
this.doCall((inner) => inner.fullTextSearch(query, columns)); | ||
return this; | ||
} | ||
/** | ||
@@ -103,0 +116,0 @@ * Return only the specified columns. |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { type AxiosResponse } from "axios"; | ||
@@ -3,0 +2,0 @@ import { Table as ArrowTable } from "../arrow"; |
@@ -15,3 +15,3 @@ "use strict"; | ||
#client; | ||
#tableCache = new util_1.TTLCache(300000); | ||
#tableCache = new util_1.TTLCache(300_000); | ||
constructor(url, { apiKey, region, hostOverride, timeout }) { | ||
@@ -18,0 +18,0 @@ super(); |
@@ -16,3 +16,24 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sanitizeTable = exports.sanitizeSchema = exports.sanitizeField = exports.sanitizeType = exports.sanitizeDictionary = exports.sanitizeDuration = exports.sanitizeMap = exports.sanitizeFixedSizeList = exports.sanitizeFixedSizeBinary = exports.sanitizeTypedUnion = exports.sanitizeUnion = exports.sanitizeStruct = exports.sanitizeList = exports.sanitizeInterval = exports.sanitizeTypedTimestamp = exports.sanitizeTimestamp = exports.sanitizeTime = exports.sanitizeDate = exports.sanitizeDecimal = exports.sanitizeFloat = exports.sanitizeInt = exports.sanitizeMetadata = void 0; | ||
exports.sanitizeMetadata = sanitizeMetadata; | ||
exports.sanitizeInt = sanitizeInt; | ||
exports.sanitizeFloat = sanitizeFloat; | ||
exports.sanitizeDecimal = sanitizeDecimal; | ||
exports.sanitizeDate = sanitizeDate; | ||
exports.sanitizeTime = sanitizeTime; | ||
exports.sanitizeTimestamp = sanitizeTimestamp; | ||
exports.sanitizeTypedTimestamp = sanitizeTypedTimestamp; | ||
exports.sanitizeInterval = sanitizeInterval; | ||
exports.sanitizeList = sanitizeList; | ||
exports.sanitizeStruct = sanitizeStruct; | ||
exports.sanitizeUnion = sanitizeUnion; | ||
exports.sanitizeTypedUnion = sanitizeTypedUnion; | ||
exports.sanitizeFixedSizeBinary = sanitizeFixedSizeBinary; | ||
exports.sanitizeFixedSizeList = sanitizeFixedSizeList; | ||
exports.sanitizeMap = sanitizeMap; | ||
exports.sanitizeDuration = sanitizeDuration; | ||
exports.sanitizeDictionary = sanitizeDictionary; | ||
exports.sanitizeType = sanitizeType; | ||
exports.sanitizeField = sanitizeField; | ||
exports.sanitizeSchema = sanitizeSchema; | ||
exports.sanitizeTable = sanitizeTable; | ||
// The utilities in this file help sanitize data from the user's arrow | ||
@@ -41,3 +62,2 @@ // library into the types expected by vectordb's arrow library. Node | ||
} | ||
exports.sanitizeMetadata = sanitizeMetadata; | ||
function sanitizeInt(typeLike) { | ||
@@ -52,3 +72,2 @@ if (!("bitWidth" in typeLike) || | ||
} | ||
exports.sanitizeInt = sanitizeInt; | ||
function sanitizeFloat(typeLike) { | ||
@@ -60,3 +79,2 @@ if (!("precision" in typeLike) || typeof typeLike.precision !== "number") { | ||
} | ||
exports.sanitizeFloat = sanitizeFloat; | ||
function sanitizeDecimal(typeLike) { | ||
@@ -73,3 +91,2 @@ if (!("scale" in typeLike) || | ||
} | ||
exports.sanitizeDecimal = sanitizeDecimal; | ||
function sanitizeDate(typeLike) { | ||
@@ -81,3 +98,2 @@ if (!("unit" in typeLike) || typeof typeLike.unit !== "number") { | ||
} | ||
exports.sanitizeDate = sanitizeDate; | ||
function sanitizeTime(typeLike) { | ||
@@ -92,3 +108,2 @@ if (!("unit" in typeLike) || | ||
} | ||
exports.sanitizeTime = sanitizeTime; | ||
function sanitizeTimestamp(typeLike) { | ||
@@ -104,3 +119,2 @@ if (!("unit" in typeLike) || typeof typeLike.unit !== "number") { | ||
} | ||
exports.sanitizeTimestamp = sanitizeTimestamp; | ||
function sanitizeTypedTimestamp(typeLike, | ||
@@ -115,3 +129,2 @@ // eslint-disable-next-line @typescript-eslint/naming-convention | ||
} | ||
exports.sanitizeTypedTimestamp = sanitizeTypedTimestamp; | ||
function sanitizeInterval(typeLike) { | ||
@@ -123,3 +136,2 @@ if (!("unit" in typeLike) || typeof typeLike.unit !== "number") { | ||
} | ||
exports.sanitizeInterval = sanitizeInterval; | ||
function sanitizeList(typeLike) { | ||
@@ -134,3 +146,2 @@ if (!("children" in typeLike) || !Array.isArray(typeLike.children)) { | ||
} | ||
exports.sanitizeList = sanitizeList; | ||
function sanitizeStruct(typeLike) { | ||
@@ -142,3 +153,2 @@ if (!("children" in typeLike) || !Array.isArray(typeLike.children)) { | ||
} | ||
exports.sanitizeStruct = sanitizeStruct; | ||
function sanitizeUnion(typeLike) { | ||
@@ -157,3 +167,2 @@ if (!("typeIds" in typeLike) || | ||
} | ||
exports.sanitizeUnion = sanitizeUnion; | ||
function sanitizeTypedUnion(typeLike, | ||
@@ -170,3 +179,2 @@ // eslint-disable-next-line @typescript-eslint/naming-convention | ||
} | ||
exports.sanitizeTypedUnion = sanitizeTypedUnion; | ||
function sanitizeFixedSizeBinary(typeLike) { | ||
@@ -178,3 +186,2 @@ if (!("byteWidth" in typeLike) || typeof typeLike.byteWidth !== "number") { | ||
} | ||
exports.sanitizeFixedSizeBinary = sanitizeFixedSizeBinary; | ||
function sanitizeFixedSizeList(typeLike) { | ||
@@ -192,3 +199,2 @@ if (!("listSize" in typeLike) || typeof typeLike.listSize !== "number") { | ||
} | ||
exports.sanitizeFixedSizeList = sanitizeFixedSizeList; | ||
function sanitizeMap(typeLike) { | ||
@@ -205,3 +211,2 @@ if (!("children" in typeLike) || !Array.isArray(typeLike.children)) { | ||
} | ||
exports.sanitizeMap = sanitizeMap; | ||
function sanitizeDuration(typeLike) { | ||
@@ -213,3 +218,2 @@ if (!("unit" in typeLike) || typeof typeLike.unit !== "number") { | ||
} | ||
exports.sanitizeDuration = sanitizeDuration; | ||
function sanitizeDictionary(typeLike) { | ||
@@ -230,3 +234,2 @@ if (!("id" in typeLike) || typeof typeLike.id !== "number") { | ||
} | ||
exports.sanitizeDictionary = sanitizeDictionary; | ||
// biome-ignore lint/suspicious/noExplicitAny: skip | ||
@@ -355,3 +358,2 @@ function sanitizeType(typeLike) { | ||
} | ||
exports.sanitizeType = sanitizeType; | ||
function sanitizeField(fieldLike) { | ||
@@ -384,3 +386,2 @@ if (fieldLike instanceof arrow_1.Field) { | ||
} | ||
exports.sanitizeField = sanitizeField; | ||
/** | ||
@@ -413,3 +414,2 @@ * Convert something schemaLike into a Schema instance | ||
} | ||
exports.sanitizeSchema = sanitizeSchema; | ||
function sanitizeTable(tableLike) { | ||
@@ -432,3 +432,2 @@ if (tableLike instanceof arrow_1.Table) { | ||
} | ||
exports.sanitizeTable = sanitizeTable; | ||
function sanitizeRecordBatch(batchLike) { | ||
@@ -435,0 +434,0 @@ if (batchLike instanceof arrow_1.RecordBatch) { |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Table as ArrowTable, Data, IntoVector, Schema, TableLike } from "./arrow"; | ||
@@ -221,17 +220,13 @@ import { CreateTableOptions } from "./connection"; | ||
* Create a search query to find the nearest neighbors | ||
* of the given query vector | ||
* @param {string} query - the query. This will be converted to a vector using the table's provided embedding function | ||
* @note If no embedding functions are defined in the table, this will error when collecting the results. | ||
* of the given query | ||
* @param {string | IntoVector} query - the query, a vector or string | ||
* @param {string} queryType - the type of the query, "vector", "fts", or "auto" | ||
* @param {string | string[]} ftsColumns - the columns to search in for full text search | ||
* for now, only one column can be searched at a time. | ||
* | ||
* This is just a convenience method for calling `.query().nearestTo(await myEmbeddingFunction(query))` | ||
* when "auto" is used, if the query is a string and an embedding function is defined, it will be treated as a vector query | ||
* if the query is a string and no embedding function is defined, it will be treated as a full text search query | ||
*/ | ||
abstract search(query: string): VectorQuery; | ||
abstract search(query: string | IntoVector, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query; | ||
/** | ||
* Create a search query to find the nearest neighbors | ||
* of the given query vector | ||
* @param {IntoVector} query - the query vector | ||
* This is just a convenience method for calling `.query().nearestTo(query)` | ||
*/ | ||
abstract search(query: IntoVector): VectorQuery; | ||
/** | ||
* Search the table with a given query vector. | ||
@@ -385,3 +380,3 @@ * | ||
query(): Query; | ||
search(query: string | IntoVector): VectorQuery; | ||
search(query: string | IntoVector, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query; | ||
vectorSearch(vector: IntoVector): VectorQuery; | ||
@@ -388,0 +383,0 @@ addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>; |
@@ -160,19 +160,33 @@ "use strict"; | ||
} | ||
search(query) { | ||
search(query, queryType = "auto", ftsColumns) { | ||
if (typeof query !== "string") { | ||
if (queryType === "fts") { | ||
throw new Error("Cannot perform full text search on a vector query"); | ||
} | ||
return this.vectorSearch(query); | ||
} | ||
else { | ||
const queryPromise = this.getEmbeddingFunctions().then(async (functions) => { | ||
// TODO: Support multiple embedding functions | ||
const embeddingFunc = functions | ||
.values() | ||
.next().value; | ||
if (!embeddingFunc) { | ||
return Promise.reject(new Error("No embedding functions are defined in the table")); | ||
} | ||
return await embeddingFunc.function.computeQueryEmbeddings(query); | ||
// If the query is a string, we need to determine if it is a vector query or a full text search query | ||
if (queryType === "fts") { | ||
return this.query().fullTextSearch(query, { | ||
columns: ftsColumns, | ||
}); | ||
return this.query().nearestTo(queryPromise); | ||
} | ||
// The query type is auto or vector | ||
// fall back to full text search if no embedding functions are defined and the query is a string | ||
if (queryType === "auto" && (0, registry_1.getRegistry)().length() === 0) { | ||
return this.query().fullTextSearch(query, { | ||
columns: ftsColumns, | ||
}); | ||
} | ||
const queryPromise = this.getEmbeddingFunctions().then(async (functions) => { | ||
// TODO: Support multiple embedding functions | ||
const embeddingFunc = functions | ||
.values() | ||
.next().value; | ||
if (!embeddingFunc) { | ||
return Promise.reject(new Error("No embedding functions are defined in the table")); | ||
} | ||
return await embeddingFunc.function.computeQueryEmbeddings(query); | ||
}); | ||
return this.query().nearestTo(queryPromise); | ||
} | ||
@@ -179,0 +193,0 @@ vectorSearch(vector) { |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
export type IntoSql = string | number | boolean | null | Date | ArrayBufferLike | Buffer | IntoSql[]; | ||
@@ -3,0 +2,0 @@ export declare function toSQL(value: IntoSql): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TTLCache = exports.toSQL = void 0; | ||
exports.TTLCache = void 0; | ||
exports.toSQL = toSQL; | ||
function toSQL(value) { | ||
@@ -33,3 +34,2 @@ if (typeof value === "string") { | ||
} | ||
exports.toSQL = toSQL; | ||
class TTLCache { | ||
@@ -36,0 +36,0 @@ ttl; |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "0.9.0", | ||
"version": "0.10.0-beta.0", | ||
"main": "dist/index.js", | ||
@@ -57,3 +57,3 @@ "exports": { | ||
"typedoc-plugin-markdown": "^4.2.1", | ||
"typescript": "^5.3.3", | ||
"typescript": "^5.5.4", | ||
"typescript-eslint": "^7.1.0" | ||
@@ -97,7 +97,7 @@ }, | ||
"optionalDependencies": { | ||
"@lancedb/lancedb-darwin-arm64": "0.9.0", | ||
"@lancedb/lancedb-linux-arm64-gnu": "0.9.0", | ||
"@lancedb/lancedb-darwin-x64": "0.9.0", | ||
"@lancedb/lancedb-linux-x64-gnu": "0.9.0", | ||
"@lancedb/lancedb-win32-x64-msvc": "0.9.0" | ||
"@lancedb/lancedb-darwin-arm64": "0.10.0-beta.0", | ||
"@lancedb/lancedb-linux-arm64-gnu": "0.10.0-beta.0", | ||
"@lancedb/lancedb-darwin-x64": "0.10.0-beta.0", | ||
"@lancedb/lancedb-linux-x64-gnu": "0.10.0-beta.0", | ||
"@lancedb/lancedb-win32-x64-msvc": "0.10.0-beta.0" | ||
}, | ||
@@ -104,0 +104,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
234155
5577