@mastra/lance 1.0.3 → 1.0.4
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/CHANGELOG.md +26 -0
- package/dist/docs/SKILL.md +4 -4
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-rag-vector-databases.md +13 -13
- package/dist/docs/references/reference-storage-lance.md +8 -8
- package/dist/docs/references/reference-vectors-lance.md +68 -60
- package/dist/index.cjs +133 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +133 -25
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +13 -0
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @mastra/lance
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added resilient column handling to insert and update operations. Unknown columns in records are now silently dropped instead of causing SQL errors, ensuring forward compatibility when newer domain packages add fields that haven't been migrated yet. ([#14021](https://github.com/mastra-ai/mastra/pull/14021))
|
|
8
|
+
|
|
9
|
+
For example, calling `db.insert({ tableName, record: { id: '1', title: 'Hello', futureField: 'value' } })` will silently ignore `futureField` if it doesn't exist in the database table, rather than throwing. The same applies to `update` — unknown fields in the data payload are dropped before building the SQL statement.
|
|
10
|
+
|
|
11
|
+
- Improved semantic recall performance for large message histories. Semantic recall no longer loads entire threads when only the recalled messages are needed, eliminating delays that previously scaled with total message count. (Fixes #11702) ([#14022](https://github.com/mastra-ai/mastra/pull/14022))
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`4f71b43`](https://github.com/mastra-ai/mastra/commit/4f71b436a4a6b8839842d8da47b57b84509af56c), [`a070277`](https://github.com/mastra-ai/mastra/commit/a07027766ce195ba74d0783116d894cbab25d44c), [`b628b91`](https://github.com/mastra-ai/mastra/commit/b628b9128b372c0f54214d902b07279f03443900), [`332c014`](https://github.com/mastra-ai/mastra/commit/332c014e076b81edf7fe45b58205882726415e90), [`6b63153`](https://github.com/mastra-ai/mastra/commit/6b63153878ea841c0f4ce632ba66bb33e57e9c1b), [`4246e34`](https://github.com/mastra-ai/mastra/commit/4246e34cec9c26636d0965942268e6d07c346671), [`b8837ee`](https://github.com/mastra-ai/mastra/commit/b8837ee77e2e84197609762bfabd8b3da326d30c), [`866cc2c`](https://github.com/mastra-ai/mastra/commit/866cc2cb1f0e3b314afab5194f69477fada745d1), [`5d950f7`](https://github.com/mastra-ai/mastra/commit/5d950f7bf426a215a1808f0abef7de5c8336ba1c), [`28c85b1`](https://github.com/mastra-ai/mastra/commit/28c85b184fc32b40f7f160483c982da6d388ecbd), [`e9a08fb`](https://github.com/mastra-ai/mastra/commit/e9a08fbef1ada7e50e961e2f54f55e8c10b4a45c), [`1d0a8a8`](https://github.com/mastra-ai/mastra/commit/1d0a8a8acf33203d5744fc429b090ad8598aa8ed), [`631ffd8`](https://github.com/mastra-ai/mastra/commit/631ffd82fed108648b448b28e6a90e38c5f53bf5), [`6bcbf8a`](https://github.com/mastra-ai/mastra/commit/6bcbf8a6774d5a53b21d61db8a45ce2593ca1616), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`aa61f29`](https://github.com/mastra-ai/mastra/commit/aa61f29ff8095ce46a4ae16e46c4d8c79b2b685b), [`7ff3714`](https://github.com/mastra-ai/mastra/commit/7ff37148515439bb3be009a60e02c3e363299760), [`18c3a90`](https://github.com/mastra-ai/mastra/commit/18c3a90c9e48cf69500e308affeb8eba5860b2af), [`41d79a1`](https://github.com/mastra-ai/mastra/commit/41d79a14bd8cb6de1e2565fd0a04786bae2f211b), [`f35487b`](https://github.com/mastra-ai/mastra/commit/f35487bb2d46c636e22aa71d90025613ae38235a), [`6dc2192`](https://github.com/mastra-ai/mastra/commit/6dc21921aef0f0efab15cd0805fa3d18f277a76f), [`eeb3a3f`](https://github.com/mastra-ai/mastra/commit/eeb3a3f43aca10cf49479eed2a84b7d9ecea02ba), [`e673376`](https://github.com/mastra-ai/mastra/commit/e6733763ad1321aa7e5ae15096b9c2104f93b1f3), [`05f8d90`](https://github.com/mastra-ai/mastra/commit/05f8d9009290ce6aa03428b3add635268615db85), [`b2204c9`](https://github.com/mastra-ai/mastra/commit/b2204c98a42848bbfb6f0440f005dc2b6354f1cd), [`a1bf1e3`](https://github.com/mastra-ai/mastra/commit/a1bf1e385ed4c0ef6f11b56c5887442970d127f2), [`b6f647a`](https://github.com/mastra-ai/mastra/commit/b6f647ae2388e091f366581595feb957e37d5b40), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`b081f27`](https://github.com/mastra-ai/mastra/commit/b081f272cf411716e1d6bd72ceac4bcee2657b19), [`4b8da97`](https://github.com/mastra-ai/mastra/commit/4b8da97a5ce306e97869df6c39535d9069e563db), [`0c09eac`](https://github.com/mastra-ai/mastra/commit/0c09eacb1926f64cfdc9ae5c6d63385cf8c9f72c), [`6b9b93d`](https://github.com/mastra-ai/mastra/commit/6b9b93d6f459d1ba6e36f163abf62a085ddb3d64), [`31b6067`](https://github.com/mastra-ai/mastra/commit/31b6067d0cc3ab10e1b29c36147f3b5266bc714a), [`797ac42`](https://github.com/mastra-ai/mastra/commit/797ac4276de231ad2d694d9aeca75980f6cd0419), [`0bc289e`](https://github.com/mastra-ai/mastra/commit/0bc289e2d476bf46c5b91c21969e8d0c6864691c), [`9b75a06`](https://github.com/mastra-ai/mastra/commit/9b75a06e53ebb0b950ba7c1e83a0142047185f46), [`4c3a1b1`](https://github.com/mastra-ai/mastra/commit/4c3a1b122ea083e003d71092f30f3b31680b01c0), [`256df35`](https://github.com/mastra-ai/mastra/commit/256df3571d62beb3ad4971faa432927cc140e603), [`85cc3b3`](https://github.com/mastra-ai/mastra/commit/85cc3b3b6f32ae4b083c26498f50d5b250ba944b), [`97ea28c`](https://github.com/mastra-ai/mastra/commit/97ea28c746e9e4147d56047bbb1c4a92417a3fec), [`d567299`](https://github.com/mastra-ai/mastra/commit/d567299cf81e02bd9d5221d4bc05967d6c224161), [`716ffe6`](https://github.com/mastra-ai/mastra/commit/716ffe68bed81f7c2690bc8581b9e140f7bf1c3d), [`8296332`](https://github.com/mastra-ai/mastra/commit/8296332de21c16e3dfc3d0b2d615720a6dc88f2f), [`4df2116`](https://github.com/mastra-ai/mastra/commit/4df211619dd922c047d396ca41cd7027c8c4c8e7), [`2219c1a`](https://github.com/mastra-ai/mastra/commit/2219c1acbd21da116da877f0036ffb985a9dd5a3), [`17c4145`](https://github.com/mastra-ai/mastra/commit/17c4145166099354545582335b5252bdfdfd908b)]:
|
|
14
|
+
- @mastra/core@1.11.0
|
|
15
|
+
|
|
16
|
+
## 1.0.4-alpha.0
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Added resilient column handling to insert and update operations. Unknown columns in records are now silently dropped instead of causing SQL errors, ensuring forward compatibility when newer domain packages add fields that haven't been migrated yet. ([#14021](https://github.com/mastra-ai/mastra/pull/14021))
|
|
21
|
+
|
|
22
|
+
For example, calling `db.insert({ tableName, record: { id: '1', title: 'Hello', futureField: 'value' } })` will silently ignore `futureField` if it doesn't exist in the database table, rather than throwing. The same applies to `update` — unknown fields in the data payload are dropped before building the SQL statement.
|
|
23
|
+
|
|
24
|
+
- Improved semantic recall performance for large message histories. Semantic recall no longer loads entire threads when only the recalled messages are needed, eliminating delays that previously scaled with total message count. (Fixes #11702) ([#14022](https://github.com/mastra-ai/mastra/pull/14022))
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [[`4f71b43`](https://github.com/mastra-ai/mastra/commit/4f71b436a4a6b8839842d8da47b57b84509af56c), [`a070277`](https://github.com/mastra-ai/mastra/commit/a07027766ce195ba74d0783116d894cbab25d44c), [`b628b91`](https://github.com/mastra-ai/mastra/commit/b628b9128b372c0f54214d902b07279f03443900), [`332c014`](https://github.com/mastra-ai/mastra/commit/332c014e076b81edf7fe45b58205882726415e90), [`6b63153`](https://github.com/mastra-ai/mastra/commit/6b63153878ea841c0f4ce632ba66bb33e57e9c1b), [`4246e34`](https://github.com/mastra-ai/mastra/commit/4246e34cec9c26636d0965942268e6d07c346671), [`b8837ee`](https://github.com/mastra-ai/mastra/commit/b8837ee77e2e84197609762bfabd8b3da326d30c), [`5d950f7`](https://github.com/mastra-ai/mastra/commit/5d950f7bf426a215a1808f0abef7de5c8336ba1c), [`28c85b1`](https://github.com/mastra-ai/mastra/commit/28c85b184fc32b40f7f160483c982da6d388ecbd), [`e9a08fb`](https://github.com/mastra-ai/mastra/commit/e9a08fbef1ada7e50e961e2f54f55e8c10b4a45c), [`631ffd8`](https://github.com/mastra-ai/mastra/commit/631ffd82fed108648b448b28e6a90e38c5f53bf5), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`aa61f29`](https://github.com/mastra-ai/mastra/commit/aa61f29ff8095ce46a4ae16e46c4d8c79b2b685b), [`7ff3714`](https://github.com/mastra-ai/mastra/commit/7ff37148515439bb3be009a60e02c3e363299760), [`41d79a1`](https://github.com/mastra-ai/mastra/commit/41d79a14bd8cb6de1e2565fd0a04786bae2f211b), [`e673376`](https://github.com/mastra-ai/mastra/commit/e6733763ad1321aa7e5ae15096b9c2104f93b1f3), [`b2204c9`](https://github.com/mastra-ai/mastra/commit/b2204c98a42848bbfb6f0440f005dc2b6354f1cd), [`a1bf1e3`](https://github.com/mastra-ai/mastra/commit/a1bf1e385ed4c0ef6f11b56c5887442970d127f2), [`b6f647a`](https://github.com/mastra-ai/mastra/commit/b6f647ae2388e091f366581595feb957e37d5b40), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`b081f27`](https://github.com/mastra-ai/mastra/commit/b081f272cf411716e1d6bd72ceac4bcee2657b19), [`0c09eac`](https://github.com/mastra-ai/mastra/commit/0c09eacb1926f64cfdc9ae5c6d63385cf8c9f72c), [`6b9b93d`](https://github.com/mastra-ai/mastra/commit/6b9b93d6f459d1ba6e36f163abf62a085ddb3d64), [`31b6067`](https://github.com/mastra-ai/mastra/commit/31b6067d0cc3ab10e1b29c36147f3b5266bc714a), [`797ac42`](https://github.com/mastra-ai/mastra/commit/797ac4276de231ad2d694d9aeca75980f6cd0419), [`0bc289e`](https://github.com/mastra-ai/mastra/commit/0bc289e2d476bf46c5b91c21969e8d0c6864691c), [`9b75a06`](https://github.com/mastra-ai/mastra/commit/9b75a06e53ebb0b950ba7c1e83a0142047185f46), [`4c3a1b1`](https://github.com/mastra-ai/mastra/commit/4c3a1b122ea083e003d71092f30f3b31680b01c0), [`85cc3b3`](https://github.com/mastra-ai/mastra/commit/85cc3b3b6f32ae4b083c26498f50d5b250ba944b), [`97ea28c`](https://github.com/mastra-ai/mastra/commit/97ea28c746e9e4147d56047bbb1c4a92417a3fec), [`d567299`](https://github.com/mastra-ai/mastra/commit/d567299cf81e02bd9d5221d4bc05967d6c224161), [`716ffe6`](https://github.com/mastra-ai/mastra/commit/716ffe68bed81f7c2690bc8581b9e140f7bf1c3d), [`8296332`](https://github.com/mastra-ai/mastra/commit/8296332de21c16e3dfc3d0b2d615720a6dc88f2f), [`4df2116`](https://github.com/mastra-ai/mastra/commit/4df211619dd922c047d396ca41cd7027c8c4c8e7), [`2219c1a`](https://github.com/mastra-ai/mastra/commit/2219c1acbd21da116da877f0036ffb985a9dd5a3), [`17c4145`](https://github.com/mastra-ai/mastra/commit/17c4145166099354545582335b5252bdfdfd908b)]:
|
|
27
|
+
- @mastra/core@1.11.0-alpha.0
|
|
28
|
+
|
|
3
29
|
## 1.0.3
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-lance
|
|
|
3
3
|
description: Documentation for @mastra/lance. Use when working with @mastra/lance APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/lance"
|
|
6
|
-
version: "1.0.
|
|
6
|
+
version: "1.0.4"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,12 +16,12 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
|
-
- [Storing
|
|
19
|
+
- [Storing embeddings in a vector database](references/docs-rag-vector-databases.md) - Guide on vector storage options in Mastra, including embedded and dedicated vector databases for similarity search.
|
|
20
20
|
|
|
21
21
|
### Reference
|
|
22
22
|
|
|
23
|
-
- [Reference: LanceDB
|
|
24
|
-
- [Reference: Lance
|
|
23
|
+
- [Reference: LanceDB storage](references/reference-storage-lance.md) - Documentation for the LanceDB storage implementation in Mastra.
|
|
24
|
+
- [Reference: Lance vector store](references/reference-vectors-lance.md) - Documentation for the LanceVectorStore class in Mastra, which provides vector search using LanceDB, an embedded vector database based on the Lance columnar format.
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Storing
|
|
1
|
+
# Storing embeddings in a vector database
|
|
2
2
|
|
|
3
3
|
After generating embeddings, you need to store them in a database that supports vector similarity search. Mastra provides a consistent interface for storing and querying embeddings across various vector databases.
|
|
4
4
|
|
|
5
|
-
## Supported
|
|
5
|
+
## Supported databases
|
|
6
6
|
|
|
7
7
|
**MongoDB**:
|
|
8
8
|
|
|
@@ -234,7 +234,7 @@ await store.upsert({
|
|
|
234
234
|
})
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
**
|
|
237
|
+
**Elasticsearch**:
|
|
238
238
|
|
|
239
239
|
```ts
|
|
240
240
|
import { ElasticSearchVector } from '@mastra/elasticsearch'
|
|
@@ -337,7 +337,7 @@ await store.upsert({
|
|
|
337
337
|
})
|
|
338
338
|
```
|
|
339
339
|
|
|
340
|
-
## Using
|
|
340
|
+
## Using vector storage
|
|
341
341
|
|
|
342
342
|
Once initialized, all vector stores share the same interface for creating indexes, upserting embeddings, and querying.
|
|
343
343
|
|
|
@@ -355,11 +355,11 @@ await store.createIndex({
|
|
|
355
355
|
|
|
356
356
|
The dimension size must match the output dimension of your chosen embedding model. Common dimension sizes are:
|
|
357
357
|
|
|
358
|
-
- OpenAI text-embedding-3-small
|
|
359
|
-
- Cohere embed-multilingual-v3
|
|
360
|
-
- Google gemini-embedding-001
|
|
358
|
+
- `OpenAI text-embedding-3-small`: 1536 dimensions (or custom, e.g., 256)
|
|
359
|
+
- `Cohere embed-multilingual-v3`: 1024 dimensions
|
|
360
|
+
- `Google gemini-embedding-001`: 768 dimensions (or custom)
|
|
361
361
|
|
|
362
|
-
> **Warning:** Index dimensions
|
|
362
|
+
> **Warning:** Index dimensions can't be changed after creation. To use a different model, delete and recreate the index with the new dimension size.
|
|
363
363
|
|
|
364
364
|
### Naming Rules for Databases
|
|
365
365
|
|
|
@@ -490,7 +490,7 @@ Index names must:
|
|
|
490
490
|
- Example: `My_Index` is not valid (contains uppercase letters)
|
|
491
491
|
- Example: `_myindex` is not valid (begins with underscore)
|
|
492
492
|
|
|
493
|
-
**
|
|
493
|
+
**Elasticsearch**:
|
|
494
494
|
|
|
495
495
|
Index names must:
|
|
496
496
|
|
|
@@ -543,7 +543,7 @@ The upsert operation:
|
|
|
543
543
|
- Creates new vectors if they don't exist
|
|
544
544
|
- Automatically handles batching for large datasets
|
|
545
545
|
|
|
546
|
-
## Adding
|
|
546
|
+
## Adding metadata
|
|
547
547
|
|
|
548
548
|
Vector stores support rich metadata (any JSON-serializable fields) for filtering and organization. Since metadata is stored with no fixed schema, use consistent field naming to avoid unexpected query results.
|
|
549
549
|
|
|
@@ -581,9 +581,9 @@ Key metadata considerations:
|
|
|
581
581
|
- Only include fields you plan to filter or sort by - extra fields add overhead
|
|
582
582
|
- Add timestamps (e.g., 'createdAt', 'lastUpdated') to track content freshness
|
|
583
583
|
|
|
584
|
-
## Deleting
|
|
584
|
+
## Deleting vectors
|
|
585
585
|
|
|
586
|
-
When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it
|
|
586
|
+
When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it straightforward to remove all embeddings associated with a specific document.
|
|
587
587
|
|
|
588
588
|
### Delete by Metadata Filter
|
|
589
589
|
|
|
@@ -637,7 +637,7 @@ await store.deleteVectors({
|
|
|
637
637
|
})
|
|
638
638
|
```
|
|
639
639
|
|
|
640
|
-
## Best
|
|
640
|
+
## Best practices
|
|
641
641
|
|
|
642
642
|
- Create indexes before bulk insertions
|
|
643
643
|
- Use batch operations for large insertions (the upsert method handles batching automatically)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# LanceDB
|
|
1
|
+
# LanceDB storage
|
|
2
2
|
|
|
3
3
|
The LanceDB storage implementation provides a high-performance storage solution using the LanceDB database system, which excels at handling both traditional data storage and vector operations.
|
|
4
4
|
|
|
5
|
-
> **Observability Not Supported:** LanceDB storage **
|
|
5
|
+
> **Observability Not Supported:** LanceDB storage **doesn't support the observability domain**. Traces from the `DefaultExporter` can't be persisted to LanceDB, and Mastra Studio's observability features won't work with LanceDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse or PostgreSQL.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -51,15 +51,15 @@ const storage = await LanceStorage.create('my-storage', 's3://bucket/db', {
|
|
|
51
51
|
|
|
52
52
|
## Parameters
|
|
53
53
|
|
|
54
|
-
### LanceStorage.create()
|
|
54
|
+
### `LanceStorage.create()`
|
|
55
55
|
|
|
56
|
-
**name
|
|
56
|
+
**name** (`string`): Name identifier for the storage instance
|
|
57
57
|
|
|
58
|
-
**uri
|
|
58
|
+
**uri** (`string`): URI to connect to the LanceDB database. Can be a local path, cloud DB URL, or S3 bucket URL
|
|
59
59
|
|
|
60
|
-
**options
|
|
60
|
+
**options** (`ConnectionOptions`): Connection options for LanceDB, such as timeout settings, authentication, etc.
|
|
61
61
|
|
|
62
|
-
## Additional
|
|
62
|
+
## Additional notes
|
|
63
63
|
|
|
64
64
|
### Schema Management
|
|
65
65
|
|
|
@@ -101,7 +101,7 @@ const memoryStore = await storage.getStore('memory')
|
|
|
101
101
|
const thread = await memoryStore?.getThreadById({ threadId: '...' })
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
> **Warning:** If `init()`
|
|
104
|
+
> **Warning:** If `init()` isn't called, tables won't be created and storage operations will fail silently or throw errors.
|
|
105
105
|
|
|
106
106
|
### Deployment Options
|
|
107
107
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# Lance
|
|
1
|
+
# Lance vector store
|
|
2
2
|
|
|
3
3
|
The LanceVectorStore class provides vector search using [LanceDB](https://lancedb.github.io/lancedb/), an embedded vector database built on the Lance columnar format. It offers efficient storage and fast similarity search for both local development and production deployments.
|
|
4
4
|
|
|
5
|
-
## Factory
|
|
5
|
+
## Factory method
|
|
6
6
|
|
|
7
7
|
The LanceVectorStore uses a factory pattern for creation. You should use the static `create()` method rather than the constructor directly.
|
|
8
8
|
|
|
9
|
-
**uri
|
|
9
|
+
**uri** (`string`): Path to LanceDB database or URI for cloud deployments
|
|
10
10
|
|
|
11
|
-
**options
|
|
11
|
+
**options** (`ConnectionOptions`): Additional connection options for LanceDB
|
|
12
12
|
|
|
13
|
-
## Constructor
|
|
13
|
+
## Constructor examples
|
|
14
14
|
|
|
15
15
|
You can create a `LanceVectorStore` instance using the static create method:
|
|
16
16
|
|
|
@@ -31,63 +31,71 @@ const s3Store = await LanceVectorStore.create('s3://bucket/db', {
|
|
|
31
31
|
|
|
32
32
|
## Methods
|
|
33
33
|
|
|
34
|
-
### createIndex()
|
|
34
|
+
### `createIndex()`
|
|
35
35
|
|
|
36
|
-
**tableName
|
|
36
|
+
**tableName** (`string`): Name of the table to create index in
|
|
37
37
|
|
|
38
|
-
**indexName
|
|
38
|
+
**indexName** (`string`): Name of the index (column name) to create
|
|
39
39
|
|
|
40
|
-
**dimension
|
|
40
|
+
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
41
41
|
|
|
42
|
-
**metric
|
|
42
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
43
43
|
|
|
44
|
-
**indexConfig
|
|
44
|
+
**indexConfig** (`LanceIndexConfig`): Index configuration (Default: `{ type: 'hnsw' }`)
|
|
45
45
|
|
|
46
|
-
#### LanceIndexConfig
|
|
46
|
+
#### `LanceIndexConfig`
|
|
47
47
|
|
|
48
|
-
**type
|
|
48
|
+
**type** (`'ivfflat' | 'hnsw'`): Index type (Default: `hnsw`)
|
|
49
49
|
|
|
50
|
-
**
|
|
50
|
+
**type.ivfflat** (`ivfflat`): Clusters vectors into lists for approximate search.
|
|
51
51
|
|
|
52
|
-
**
|
|
52
|
+
**type.hnsw** (`hnsw`): Graph-based index offering fast search times and high recall.
|
|
53
53
|
|
|
54
|
-
**
|
|
54
|
+
**numPartitions** (`number`): Number of partitions for IVF indexes (Default: `128`)
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
**numSubVectors** (`number`): Number of sub-vectors for product quantization (Default: `16`)
|
|
57
57
|
|
|
58
|
-
**
|
|
58
|
+
**hnsw** (`HNSWConfig`): HNSW configuration
|
|
59
59
|
|
|
60
|
-
**
|
|
60
|
+
**hnsw\.m** (`number`): Maximum number of connections per node (default: 16)
|
|
61
61
|
|
|
62
|
-
**
|
|
62
|
+
**hnsw\.efConstruction** (`number`): Build-time complexity (default: 100)
|
|
63
63
|
|
|
64
|
-
###
|
|
64
|
+
### `createTable()`
|
|
65
65
|
|
|
66
|
-
**tableName
|
|
66
|
+
**tableName** (`string`): Name of the table to create
|
|
67
67
|
|
|
68
|
-
**
|
|
68
|
+
**data** (`Record<string, unknown>[] | TableLike`): Initial data for the table
|
|
69
69
|
|
|
70
|
-
**
|
|
70
|
+
**options** (`Partial<CreateTableOptions>`): Additional table creation options
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
### `upsert()`
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
**tableName** (`string`): Name of the table to upsert vectors into
|
|
75
75
|
|
|
76
|
-
**
|
|
76
|
+
**vectors** (`number[][]`): Array of embedding vectors
|
|
77
77
|
|
|
78
|
-
**
|
|
78
|
+
**metadata** (`Record<string, any>[]`): Metadata for each vector
|
|
79
79
|
|
|
80
|
-
**
|
|
80
|
+
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
### `query()`
|
|
83
83
|
|
|
84
|
-
**
|
|
84
|
+
**tableName** (`string`): Name of the table to query
|
|
85
85
|
|
|
86
|
-
**
|
|
86
|
+
**queryVector** (`number[]`): Query vector
|
|
87
87
|
|
|
88
|
-
**
|
|
88
|
+
**topK** (`number`): Number of results to return (Default: `10`)
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
**filter** (`Record<string, any>`): Metadata filters
|
|
91
|
+
|
|
92
|
+
**includeVector** (`boolean`): Whether to include the vector in the result (Default: `false`)
|
|
93
|
+
|
|
94
|
+
**columns** (`string[]`): Specific columns to include in the result (Default: `[]`)
|
|
95
|
+
|
|
96
|
+
**includeAllColumns** (`boolean`): Whether to include all columns in the result (Default: `false`)
|
|
97
|
+
|
|
98
|
+
### `listTables()`
|
|
91
99
|
|
|
92
100
|
Returns an array of table names as strings.
|
|
93
101
|
|
|
@@ -96,27 +104,27 @@ const tables = await vectorStore.listTables()
|
|
|
96
104
|
// ['my_vectors', 'embeddings', 'documents']
|
|
97
105
|
```
|
|
98
106
|
|
|
99
|
-
### getTableSchema()
|
|
107
|
+
### `getTableSchema()`
|
|
100
108
|
|
|
101
|
-
**tableName
|
|
109
|
+
**tableName** (`string`): Name of the table to describe
|
|
102
110
|
|
|
103
111
|
Returns the schema of the specified table.
|
|
104
112
|
|
|
105
|
-
### deleteTable()
|
|
113
|
+
### `deleteTable()`
|
|
106
114
|
|
|
107
|
-
**tableName
|
|
115
|
+
**tableName** (`string`): Name of the table to delete
|
|
108
116
|
|
|
109
|
-
### deleteAllTables()
|
|
117
|
+
### `deleteAllTables()`
|
|
110
118
|
|
|
111
119
|
Deletes all tables in the database.
|
|
112
120
|
|
|
113
|
-
### listIndexes()
|
|
121
|
+
### `listIndexes()`
|
|
114
122
|
|
|
115
123
|
Returns an array of index names as strings.
|
|
116
124
|
|
|
117
|
-
### describeIndex()
|
|
125
|
+
### `describeIndex()`
|
|
118
126
|
|
|
119
|
-
**indexName
|
|
127
|
+
**indexName** (`string`): Name of the index to describe
|
|
120
128
|
|
|
121
129
|
Returns information about the index:
|
|
122
130
|
|
|
@@ -135,43 +143,43 @@ interface IndexStats {
|
|
|
135
143
|
}
|
|
136
144
|
```
|
|
137
145
|
|
|
138
|
-
### deleteIndex()
|
|
146
|
+
### `deleteIndex()`
|
|
139
147
|
|
|
140
|
-
**indexName
|
|
148
|
+
**indexName** (`string`): Name of the index to delete
|
|
141
149
|
|
|
142
|
-
### updateVector()
|
|
150
|
+
### `updateVector()`
|
|
143
151
|
|
|
144
152
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
145
153
|
|
|
146
|
-
**indexName
|
|
154
|
+
**indexName** (`string`): Name of the index containing the vector
|
|
147
155
|
|
|
148
|
-
**id
|
|
156
|
+
**id** (`string`): ID of the vector to update (mutually exclusive with filter)
|
|
149
157
|
|
|
150
|
-
**filter
|
|
158
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vector(s) to update (mutually exclusive with id)
|
|
151
159
|
|
|
152
|
-
**update
|
|
160
|
+
**update** (`{ vector?: number[]; metadata?: Record<string, any>; }`): Object containing the vector and/or metadata to update
|
|
153
161
|
|
|
154
|
-
### deleteVector()
|
|
162
|
+
### `deleteVector()`
|
|
155
163
|
|
|
156
|
-
**indexName
|
|
164
|
+
**indexName** (`string`): Name of the index containing the vector
|
|
157
165
|
|
|
158
|
-
**id
|
|
166
|
+
**id** (`string`): ID of the vector to delete
|
|
159
167
|
|
|
160
|
-
### deleteVectors()
|
|
168
|
+
### `deleteVectors()`
|
|
161
169
|
|
|
162
170
|
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
163
171
|
|
|
164
|
-
**indexName
|
|
172
|
+
**indexName** (`string`): Name of the index containing the vectors to delete
|
|
165
173
|
|
|
166
|
-
**ids
|
|
174
|
+
**ids** (`string[]`): Array of vector IDs to delete (mutually exclusive with filter)
|
|
167
175
|
|
|
168
|
-
**filter
|
|
176
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
|
|
169
177
|
|
|
170
|
-
### close()
|
|
178
|
+
### `close()`
|
|
171
179
|
|
|
172
180
|
Closes the database connection.
|
|
173
181
|
|
|
174
|
-
## Response
|
|
182
|
+
## Response types
|
|
175
183
|
|
|
176
184
|
Query results are returned in this format:
|
|
177
185
|
|
|
@@ -185,7 +193,7 @@ interface QueryResult {
|
|
|
185
193
|
}
|
|
186
194
|
```
|
|
187
195
|
|
|
188
|
-
## Error
|
|
196
|
+
## Error handling
|
|
189
197
|
|
|
190
198
|
The store throws typed errors that can be caught:
|
|
191
199
|
|
|
@@ -202,7 +210,7 @@ try {
|
|
|
202
210
|
}
|
|
203
211
|
```
|
|
204
212
|
|
|
205
|
-
## Best
|
|
213
|
+
## Best practices
|
|
206
214
|
|
|
207
215
|
- Use the appropriate index type for your use case:
|
|
208
216
|
|