diff --git a/docs/src/basic.md b/docs/src/basic.md index e6ee76f3..f4ee7bd7 100644 --- a/docs/src/basic.md +++ b/docs/src/basic.md @@ -122,6 +122,35 @@ After a table has been created, you can always add more data to it using {vector: [9.5, 56.2], item: "buzz", price: 200.0}]) ``` +## How to delete rows from a table + +Use the `delete()` method on tables to delete rows from a table. To choose +which rows to delete, provide a filter that matches on the metadata columns. +This can delete any number of rows that match the filter. + +=== "Python" + ```python + tbl.delete('item = "fizz"') + ``` + +=== "Javascript" + ```javascript + await tbl.delete('item = "fizz"') + ``` + +The deletion predicate is a SQL expression that supports the same expressions +as the `where()` clause on a search. They can be as simple or complex as needed. +To see what expressions are supported, see the [SQL filters](sql.md) section. + + +=== "Python" + + Read more: [lancedb.table.Table.delete][] + +=== "Javascript" + + Read more: [vectordb.Table.delete](javascript/interfaces/Table.md#delete) + ## How to search for (approximate) nearest neighbors Once you've embedded the query, you can find its nearest neighbors using the following code: diff --git a/docs/src/javascript/README.md b/docs/src/javascript/README.md index e512bae7..ce3bd86a 100644 --- a/docs/src/javascript/README.md +++ b/docs/src/javascript/README.md @@ -10,6 +10,10 @@ A JavaScript / Node.js library for [LanceDB](https://github.com/lancedb/lancedb) npm install vectordb ``` +This will download the appropriate native library for your platform. We currently +support x86_64 Linux, aarch64 Linux, Intel MacOS, and ARM (M1/M2) MacOS. We do not +yet support Windows or musl-based Linux (such as Alpine Linux). + ## Usage ### Basic Example @@ -28,12 +32,34 @@ The [examples](./examples) folder contains complete examples. ## Development -Run the tests with +To build everything fresh: + +```bash +npm install +npm run tsc +npm run build +``` + +Then you should be able to run the tests with: ```bash npm test ``` +### Rebuilding Rust library + +```bash +npm run build +``` + +### Rebuilding Typescript + +```bash +npm run tsc +``` + +### Fix lints + To run the linter and have it automatically fix all errors ```bash diff --git a/docs/src/javascript/classes/LocalConnection.md b/docs/src/javascript/classes/LocalConnection.md index e14c3f8d..c7d7afd6 100644 --- a/docs/src/javascript/classes/LocalConnection.md +++ b/docs/src/javascript/classes/LocalConnection.md @@ -17,7 +17,7 @@ A connection to a LanceDB database. ### Properties - [\_db](LocalConnection.md#_db) -- [\_uri](LocalConnection.md#_uri) +- [\_options](LocalConnection.md#_options) ### Accessors @@ -35,18 +35,18 @@ A connection to a LanceDB database. ### constructor -• **new LocalConnection**(`db`, `uri`) +• **new LocalConnection**(`db`, `options`) #### Parameters | Name | Type | | :------ | :------ | | `db` | `any` | -| `uri` | `string` | +| `options` | [`ConnectionOptions`](../interfaces/ConnectionOptions.md) | #### Defined in -[index.ts:132](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L132) +[index.ts:184](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L184) ## Properties @@ -56,17 +56,17 @@ A connection to a LanceDB database. #### Defined in -[index.ts:130](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L130) +[index.ts:182](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L182) ___ -### \_uri +### \_options -• `Private` `Readonly` **\_uri**: `string` +• `Private` `Readonly` **\_options**: [`ConnectionOptions`](../interfaces/ConnectionOptions.md) #### Defined in -[index.ts:129](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L129) +[index.ts:181](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L181) ## Accessors @@ -84,7 +84,7 @@ ___ #### Defined in -[index.ts:137](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L137) +[index.ts:189](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L189) ## Methods @@ -112,7 +112,7 @@ Creates a new Table and initialize it with new data. #### Defined in -[index.ts:177](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L177) +[index.ts:230](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L230) ▸ **createTable**(`name`, `data`, `mode`): `Promise`<[`Table`](../interfaces/Table.md)<`number`[]\>\> @@ -134,7 +134,7 @@ Connection.createTable #### Defined in -[index.ts:178](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L178) +[index.ts:231](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L231) ▸ **createTable**<`T`\>(`name`, `data`, `mode`, `embeddings`): `Promise`<[`Table`](../interfaces/Table.md)<`T`\>\> @@ -165,7 +165,36 @@ Connection.createTable #### Defined in -[index.ts:188](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L188) +[index.ts:241](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L241) + +▸ **createTable**<`T`\>(`name`, `data`, `mode`, `embeddings?`): `Promise`<[`Table`](../interfaces/Table.md)<`T`\>\> + +#### Type parameters + +| Name | +| :------ | +| `T` | + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `name` | `string` | +| `data` | `Record`<`string`, `unknown`\>[] | +| `mode` | [`WriteMode`](../enums/WriteMode.md) | +| `embeddings?` | [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)<`T`\> | + +#### Returns + +`Promise`<[`Table`](../interfaces/Table.md)<`T`\>\> + +#### Implementation of + +Connection.createTable + +#### Defined in + +[index.ts:242](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L242) ___ @@ -190,7 +219,7 @@ ___ #### Defined in -[index.ts:201](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L201) +[index.ts:266](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L266) ___ @@ -216,7 +245,7 @@ Drop an existing table. #### Defined in -[index.ts:211](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L211) +[index.ts:276](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L276) ___ @@ -242,7 +271,7 @@ Open a table in the database. #### Defined in -[index.ts:153](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L153) +[index.ts:205](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L205) ▸ **openTable**<`T`\>(`name`, `embeddings`): `Promise`<[`Table`](../interfaces/Table.md)<`T`\>\> @@ -271,7 +300,34 @@ Connection.openTable #### Defined in -[index.ts:160](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L160) +[index.ts:212](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L212) + +▸ **openTable**<`T`\>(`name`, `embeddings?`): `Promise`<[`Table`](../interfaces/Table.md)<`T`\>\> + +#### Type parameters + +| Name | +| :------ | +| `T` | + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `name` | `string` | +| `embeddings?` | [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)<`T`\> | + +#### Returns + +`Promise`<[`Table`](../interfaces/Table.md)<`T`\>\> + +#### Implementation of + +Connection.openTable + +#### Defined in + +[index.ts:213](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L213) ___ @@ -291,4 +347,4 @@ Get the names of all tables in the database. #### Defined in -[index.ts:144](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L144) +[index.ts:196](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L196) diff --git a/docs/src/javascript/classes/LocalTable.md b/docs/src/javascript/classes/LocalTable.md index 13c126e4..e3a0ee21 100644 --- a/docs/src/javascript/classes/LocalTable.md +++ b/docs/src/javascript/classes/LocalTable.md @@ -24,6 +24,7 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector - [\_embeddings](LocalTable.md#_embeddings) - [\_name](LocalTable.md#_name) +- [\_options](LocalTable.md#_options) - [\_tbl](LocalTable.md#_tbl) ### Accessors @@ -43,7 +44,7 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector ### constructor -• **new LocalTable**<`T`\>(`tbl`, `name`) +• **new LocalTable**<`T`\>(`tbl`, `name`, `options`) #### Type parameters @@ -57,12 +58,13 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector | :------ | :------ | | `tbl` | `any` | | `name` | `string` | +| `options` | [`ConnectionOptions`](../interfaces/ConnectionOptions.md) | #### Defined in -[index.ts:221](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L221) +[index.ts:287](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L287) -• **new LocalTable**<`T`\>(`tbl`, `name`, `embeddings`) +• **new LocalTable**<`T`\>(`tbl`, `name`, `options`, `embeddings`) #### Type parameters @@ -76,11 +78,12 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector | :------ | :------ | :------ | | `tbl` | `any` | | | `name` | `string` | | +| `options` | [`ConnectionOptions`](../interfaces/ConnectionOptions.md) | | | `embeddings` | [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)<`T`\> | An embedding function to use when interacting with this table | #### Defined in -[index.ts:227](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L227) +[index.ts:294](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L294) ## Properties @@ -90,7 +93,7 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector #### Defined in -[index.ts:219](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L219) +[index.ts:284](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L284) ___ @@ -100,7 +103,17 @@ ___ #### Defined in -[index.ts:218](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L218) +[index.ts:283](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L283) + +___ + +### \_options + +• `Private` `Readonly` **\_options**: [`ConnectionOptions`](../interfaces/ConnectionOptions.md) + +#### Defined in + +[index.ts:285](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L285) ___ @@ -110,7 +123,7 @@ ___ #### Defined in -[index.ts:217](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L217) +[index.ts:282](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L282) ## Accessors @@ -128,7 +141,7 @@ ___ #### Defined in -[index.ts:234](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L234) +[index.ts:302](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L302) ## Methods @@ -156,7 +169,7 @@ The number of rows added to the table #### Defined in -[index.ts:252](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L252) +[index.ts:320](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L320) ___ @@ -176,7 +189,7 @@ Returns the number of rows in this table. #### Defined in -[index.ts:278](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L278) +[index.ts:362](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L362) ___ @@ -194,7 +207,7 @@ VectorIndexParams. | Name | Type | Description | | :------ | :------ | :------ | -| `indexParams` | `IvfPQIndexConfig` | The parameters of this Index, | +| `indexParams` | [`IvfPQIndexConfig`](../interfaces/IvfPQIndexConfig.md) | The parameters of this Index, | #### Returns @@ -206,7 +219,7 @@ VectorIndexParams. #### Defined in -[index.ts:271](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L271) +[index.ts:355](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L355) ___ @@ -232,7 +245,7 @@ Delete rows from this table. #### Defined in -[index.ts:287](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L287) +[index.ts:371](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L371) ___ @@ -260,7 +273,7 @@ The number of rows added to the table #### Defined in -[index.ts:262](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L262) +[index.ts:338](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L338) ___ @@ -286,4 +299,4 @@ Creates a search query to find the nearest neighbors of the given search term #### Defined in -[index.ts:242](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L242) +[index.ts:310](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L310) diff --git a/docs/src/javascript/classes/OpenAIEmbeddingFunction.md b/docs/src/javascript/classes/OpenAIEmbeddingFunction.md index 578e514e..f2a4b864 100644 --- a/docs/src/javascript/classes/OpenAIEmbeddingFunction.md +++ b/docs/src/javascript/classes/OpenAIEmbeddingFunction.md @@ -40,7 +40,7 @@ An embedding function that automatically creates vector representation for a giv #### Defined in -[embedding/openai.ts:21](https://github.com/lancedb/lancedb/blob/7247834/node/src/embedding/openai.ts#L21) +[embedding/openai.ts:21](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/embedding/openai.ts#L21) ## Properties @@ -50,7 +50,7 @@ An embedding function that automatically creates vector representation for a giv #### Defined in -[embedding/openai.ts:19](https://github.com/lancedb/lancedb/blob/7247834/node/src/embedding/openai.ts#L19) +[embedding/openai.ts:19](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/embedding/openai.ts#L19) ___ @@ -60,7 +60,7 @@ ___ #### Defined in -[embedding/openai.ts:18](https://github.com/lancedb/lancedb/blob/7247834/node/src/embedding/openai.ts#L18) +[embedding/openai.ts:18](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/embedding/openai.ts#L18) ___ @@ -76,7 +76,7 @@ The name of the column that will be used as input for the Embedding Function. #### Defined in -[embedding/openai.ts:50](https://github.com/lancedb/lancedb/blob/7247834/node/src/embedding/openai.ts#L50) +[embedding/openai.ts:50](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/embedding/openai.ts#L50) ## Methods @@ -102,4 +102,4 @@ Creates a vector representation for the given values. #### Defined in -[embedding/openai.ts:38](https://github.com/lancedb/lancedb/blob/7247834/node/src/embedding/openai.ts#L38) +[embedding/openai.ts:38](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/embedding/openai.ts#L38) diff --git a/docs/src/javascript/classes/Query.md b/docs/src/javascript/classes/Query.md index 85c18dc2..e9371f10 100644 --- a/docs/src/javascript/classes/Query.md +++ b/docs/src/javascript/classes/Query.md @@ -62,7 +62,7 @@ A builder for nearest neighbor queries for LanceDB. #### Defined in -[index.ts:362](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L362) +[index.ts:448](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L448) ## Properties @@ -72,7 +72,7 @@ A builder for nearest neighbor queries for LanceDB. #### Defined in -[index.ts:360](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L360) +[index.ts:446](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L446) ___ @@ -82,7 +82,7 @@ ___ #### Defined in -[index.ts:358](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L358) +[index.ts:444](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L444) ___ @@ -92,7 +92,7 @@ ___ #### Defined in -[index.ts:354](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L354) +[index.ts:440](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L440) ___ @@ -102,7 +102,7 @@ ___ #### Defined in -[index.ts:359](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L359) +[index.ts:445](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L445) ___ @@ -112,7 +112,7 @@ ___ #### Defined in -[index.ts:356](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L356) +[index.ts:442](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L442) ___ @@ -122,7 +122,7 @@ ___ #### Defined in -[index.ts:352](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L352) +[index.ts:438](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L438) ___ @@ -132,7 +132,7 @@ ___ #### Defined in -[index.ts:353](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L353) +[index.ts:439](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L439) ___ @@ -142,7 +142,7 @@ ___ #### Defined in -[index.ts:355](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L355) +[index.ts:441](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L441) ___ @@ -152,7 +152,7 @@ ___ #### Defined in -[index.ts:357](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L357) +[index.ts:443](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L443) ___ @@ -162,7 +162,7 @@ ___ #### Defined in -[index.ts:351](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L351) +[index.ts:437](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L437) ___ @@ -188,7 +188,7 @@ A filter statement to be applied to this query. #### Defined in -[index.ts:410](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L410) +[index.ts:496](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L496) ## Methods @@ -210,7 +210,7 @@ Execute the query and return the results as an Array of Objects #### Defined in -[index.ts:433](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L433) +[index.ts:519](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L519) ___ @@ -232,7 +232,7 @@ A filter statement to be applied to this query. #### Defined in -[index.ts:405](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L405) +[index.ts:491](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L491) ___ @@ -254,7 +254,7 @@ Sets the number of results that will be returned #### Defined in -[index.ts:378](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L378) +[index.ts:464](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L464) ___ @@ -280,7 +280,7 @@ MetricType for the different options #### Defined in -[index.ts:425](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L425) +[index.ts:511](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L511) ___ @@ -302,7 +302,7 @@ The number of probes used. A higher number makes search more accurate but also s #### Defined in -[index.ts:396](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L396) +[index.ts:482](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L482) ___ @@ -324,7 +324,7 @@ Refine the results by reading extra elements and re-ranking them in memory. #### Defined in -[index.ts:387](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L387) +[index.ts:473](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L473) ___ @@ -346,4 +346,4 @@ Return only the specified columns. #### Defined in -[index.ts:416](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L416) +[index.ts:502](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L502) diff --git a/docs/src/javascript/enums/MetricType.md b/docs/src/javascript/enums/MetricType.md index eae398af..9a92178e 100644 --- a/docs/src/javascript/enums/MetricType.md +++ b/docs/src/javascript/enums/MetricType.md @@ -22,7 +22,7 @@ Cosine distance #### Defined in -[index.ts:481](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L481) +[index.ts:567](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L567) ___ @@ -34,7 +34,7 @@ Dot product #### Defined in -[index.ts:486](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L486) +[index.ts:572](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L572) ___ @@ -46,4 +46,4 @@ Euclidean distance #### Defined in -[index.ts:476](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L476) +[index.ts:562](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L562) diff --git a/docs/src/javascript/enums/WriteMode.md b/docs/src/javascript/enums/WriteMode.md index cac22dee..46a71f1c 100644 --- a/docs/src/javascript/enums/WriteMode.md +++ b/docs/src/javascript/enums/WriteMode.md @@ -22,7 +22,7 @@ Append new data to the table. #### Defined in -[index.ts:466](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L466) +[index.ts:552](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L552) ___ @@ -34,7 +34,7 @@ Create a new [Table](../interfaces/Table.md). #### Defined in -[index.ts:462](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L462) +[index.ts:548](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L548) ___ @@ -46,4 +46,4 @@ Overwrite the existing [Table](../interfaces/Table.md) if presented. #### Defined in -[index.ts:464](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L464) +[index.ts:550](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L550) diff --git a/docs/src/javascript/interfaces/AwsCredentials.md b/docs/src/javascript/interfaces/AwsCredentials.md new file mode 100644 index 00000000..8e583361 --- /dev/null +++ b/docs/src/javascript/interfaces/AwsCredentials.md @@ -0,0 +1,41 @@ +[vectordb](../README.md) / [Exports](../modules.md) / AwsCredentials + +# Interface: AwsCredentials + +## Table of contents + +### Properties + +- [accessKeyId](AwsCredentials.md#accesskeyid) +- [secretKey](AwsCredentials.md#secretkey) +- [sessionToken](AwsCredentials.md#sessiontoken) + +## Properties + +### accessKeyId + +• **accessKeyId**: `string` + +#### Defined in + +[index.ts:31](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L31) + +___ + +### secretKey + +• **secretKey**: `string` + +#### Defined in + +[index.ts:33](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L33) + +___ + +### sessionToken + +• `Optional` **sessionToken**: `string` + +#### Defined in + +[index.ts:35](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L35) diff --git a/docs/src/javascript/interfaces/Connection.md b/docs/src/javascript/interfaces/Connection.md index 79b91dc5..3d30703b 100644 --- a/docs/src/javascript/interfaces/Connection.md +++ b/docs/src/javascript/interfaces/Connection.md @@ -32,7 +32,7 @@ Connection could be local against filesystem or remote against a server. #### Defined in -[index.ts:45](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L45) +[index.ts:70](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L70) ## Methods @@ -63,7 +63,7 @@ Creates a new Table and initialize it with new data. #### Defined in -[index.ts:65](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L65) +[index.ts:90](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L90) ___ @@ -84,7 +84,7 @@ ___ #### Defined in -[index.ts:67](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L67) +[index.ts:92](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L92) ___ @@ -106,7 +106,7 @@ Drop an existing table. #### Defined in -[index.ts:73](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L73) +[index.ts:98](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L98) ___ @@ -135,7 +135,7 @@ Open a table in the database. #### Defined in -[index.ts:55](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L55) +[index.ts:80](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L80) ___ @@ -149,4 +149,4 @@ ___ #### Defined in -[index.ts:47](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L47) +[index.ts:72](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L72) diff --git a/docs/src/javascript/interfaces/ConnectionOptions.md b/docs/src/javascript/interfaces/ConnectionOptions.md new file mode 100644 index 00000000..c162ce7f --- /dev/null +++ b/docs/src/javascript/interfaces/ConnectionOptions.md @@ -0,0 +1,30 @@ +[vectordb](../README.md) / [Exports](../modules.md) / ConnectionOptions + +# Interface: ConnectionOptions + +## Table of contents + +### Properties + +- [awsCredentials](ConnectionOptions.md#awscredentials) +- [uri](ConnectionOptions.md#uri) + +## Properties + +### awsCredentials + +• `Optional` **awsCredentials**: [`AwsCredentials`](AwsCredentials.md) + +#### Defined in + +[index.ts:40](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L40) + +___ + +### uri + +• **uri**: `string` + +#### Defined in + +[index.ts:39](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L39) diff --git a/docs/src/javascript/interfaces/EmbeddingFunction.md b/docs/src/javascript/interfaces/EmbeddingFunction.md index 755e81df..3954b561 100644 --- a/docs/src/javascript/interfaces/EmbeddingFunction.md +++ b/docs/src/javascript/interfaces/EmbeddingFunction.md @@ -45,7 +45,7 @@ Creates a vector representation for the given values. #### Defined in -[embedding/embedding_function.ts:27](https://github.com/lancedb/lancedb/blob/7247834/node/src/embedding/embedding_function.ts#L27) +[embedding/embedding_function.ts:27](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/embedding/embedding_function.ts#L27) ___ @@ -57,4 +57,4 @@ The name of the column that will be used as input for the Embedding Function. #### Defined in -[embedding/embedding_function.ts:22](https://github.com/lancedb/lancedb/blob/7247834/node/src/embedding/embedding_function.ts#L22) +[embedding/embedding_function.ts:22](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/embedding/embedding_function.ts#L22) diff --git a/docs/src/javascript/interfaces/IvfPQIndexConfig.md b/docs/src/javascript/interfaces/IvfPQIndexConfig.md new file mode 100644 index 00000000..c2fc6327 --- /dev/null +++ b/docs/src/javascript/interfaces/IvfPQIndexConfig.md @@ -0,0 +1,149 @@ +[vectordb](../README.md) / [Exports](../modules.md) / IvfPQIndexConfig + +# Interface: IvfPQIndexConfig + +## Table of contents + +### Properties + +- [column](IvfPQIndexConfig.md#column) +- [index\_name](IvfPQIndexConfig.md#index_name) +- [max\_iters](IvfPQIndexConfig.md#max_iters) +- [max\_opq\_iters](IvfPQIndexConfig.md#max_opq_iters) +- [metric\_type](IvfPQIndexConfig.md#metric_type) +- [num\_bits](IvfPQIndexConfig.md#num_bits) +- [num\_partitions](IvfPQIndexConfig.md#num_partitions) +- [num\_sub\_vectors](IvfPQIndexConfig.md#num_sub_vectors) +- [replace](IvfPQIndexConfig.md#replace) +- [type](IvfPQIndexConfig.md#type) +- [use\_opq](IvfPQIndexConfig.md#use_opq) + +## Properties + +### column + +• `Optional` **column**: `string` + +The column to be indexed + +#### Defined in + +[index.ts:382](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L382) + +___ + +### index\_name + +• `Optional` **index\_name**: `string` + +A unique name for the index + +#### Defined in + +[index.ts:387](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L387) + +___ + +### max\_iters + +• `Optional` **max\_iters**: `number` + +The max number of iterations for kmeans training. + +#### Defined in + +[index.ts:402](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L402) + +___ + +### max\_opq\_iters + +• `Optional` **max\_opq\_iters**: `number` + +Max number of iterations to train OPQ, if `use_opq` is true. + +#### Defined in + +[index.ts:421](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L421) + +___ + +### metric\_type + +• `Optional` **metric\_type**: [`MetricType`](../enums/MetricType.md) + +Metric type, L2 or Cosine + +#### Defined in + +[index.ts:392](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L392) + +___ + +### num\_bits + +• `Optional` **num\_bits**: `number` + +The number of bits to present one PQ centroid. + +#### Defined in + +[index.ts:416](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L416) + +___ + +### num\_partitions + +• `Optional` **num\_partitions**: `number` + +The number of partitions this index + +#### Defined in + +[index.ts:397](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L397) + +___ + +### num\_sub\_vectors + +• `Optional` **num\_sub\_vectors**: `number` + +Number of subvectors to build PQ code + +#### Defined in + +[index.ts:412](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L412) + +___ + +### replace + +• `Optional` **replace**: `boolean` + +Replace an existing index with the same name if it exists. + +#### Defined in + +[index.ts:426](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L426) + +___ + +### type + +• **type**: ``"ivf_pq"`` + +#### Defined in + +[index.ts:428](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L428) + +___ + +### use\_opq + +• `Optional` **use\_opq**: `boolean` + +Train as optimized product quantization. + +#### Defined in + +[index.ts:407](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L407) diff --git a/docs/src/javascript/interfaces/Table.md b/docs/src/javascript/interfaces/Table.md index be07d118..32db661e 100644 --- a/docs/src/javascript/interfaces/Table.md +++ b/docs/src/javascript/interfaces/Table.md @@ -52,7 +52,7 @@ The number of rows added to the table #### Defined in -[index.ts:95](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L95) +[index.ts:120](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L120) ___ @@ -72,13 +72,13 @@ Returns the number of rows in this table. #### Defined in -[index.ts:115](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L115) +[index.ts:140](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L140) ___ ### createIndex -• **createIndex**: (`indexParams`: `IvfPQIndexConfig`) => `Promise`<`any`\> +• **createIndex**: (`indexParams`: [`IvfPQIndexConfig`](IvfPQIndexConfig.md)) => `Promise`<`any`\> #### Type declaration @@ -94,7 +94,7 @@ VectorIndexParams. | Name | Type | Description | | :------ | :------ | :------ | -| `indexParams` | `IvfPQIndexConfig` | The parameters of this Index, | +| `indexParams` | [`IvfPQIndexConfig`](IvfPQIndexConfig.md) | The parameters of this Index, | ##### Returns @@ -102,7 +102,7 @@ VectorIndexParams. #### Defined in -[index.ts:110](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L110) +[index.ts:135](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L135) ___ @@ -116,11 +116,37 @@ ___ Delete rows from this table. +This can be used to delete a single row, many rows, all rows, or +sometimes no rows (if your predicate matches nothing). + +**`Examples`** + +```ts +const con = await lancedb.connect("./.lancedb") +const data = [ + {id: 1, vector: [1, 2]}, + {id: 2, vector: [3, 4]}, + {id: 3, vector: [5, 6]}, +]; +const tbl = await con.createTable("my_table", data) +await tbl.delete("id = 2") +await tbl.countRows() // Returns 2 +``` + +If you have a list of values to delete, you can combine them into a +stringified list and use the `IN` operator: + +```ts +const to_remove = [1, 5]; +await tbl.delete(`id IN (${to_remove.join(",")})`) +await tbl.countRows() // Returns 1 +``` + ##### Parameters | Name | Type | Description | | :------ | :------ | :------ | -| `filter` | `string` | A filter in the same format used by a sql WHERE clause. | +| `filter` | `string` | A filter in the same format used by a sql WHERE clause. The filter must not be empty. | ##### Returns @@ -128,7 +154,7 @@ Delete rows from this table. #### Defined in -[index.ts:122](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L122) +[index.ts:174](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L174) ___ @@ -138,7 +164,7 @@ ___ #### Defined in -[index.ts:81](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L81) +[index.ts:106](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L106) ___ @@ -166,7 +192,7 @@ The number of rows added to the table #### Defined in -[index.ts:103](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L103) +[index.ts:128](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L128) ___ @@ -192,4 +218,4 @@ Creates a search query to find the nearest neighbors of the given search term #### Defined in -[index.ts:87](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L87) +[index.ts:112](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L112) diff --git a/docs/src/javascript/modules.md b/docs/src/javascript/modules.md index abd004b0..ab18bf5b 100644 --- a/docs/src/javascript/modules.md +++ b/docs/src/javascript/modules.md @@ -18,8 +18,11 @@ ### Interfaces +- [AwsCredentials](interfaces/AwsCredentials.md) - [Connection](interfaces/Connection.md) +- [ConnectionOptions](interfaces/ConnectionOptions.md) - [EmbeddingFunction](interfaces/EmbeddingFunction.md) +- [IvfPQIndexConfig](interfaces/IvfPQIndexConfig.md) - [Table](interfaces/Table.md) ### Type Aliases @@ -34,11 +37,11 @@ ### VectorIndexParams -Ƭ **VectorIndexParams**: `IvfPQIndexConfig` +Ƭ **VectorIndexParams**: [`IvfPQIndexConfig`](interfaces/IvfPQIndexConfig.md) #### Defined in -[index.ts:345](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L345) +[index.ts:431](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L431) ## Functions @@ -60,4 +63,20 @@ Connect to a LanceDB instance at the given URI #### Defined in -[index.ts:34](https://github.com/lancedb/lancedb/blob/7247834/node/src/index.ts#L34) +[index.ts:47](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L47) + +▸ **connect**(`opts`): `Promise`<[`Connection`](interfaces/Connection.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `opts` | `Partial`<[`ConnectionOptions`](interfaces/ConnectionOptions.md)\> | + +#### Returns + +`Promise`<[`Connection`](interfaces/Connection.md)\> + +#### Defined in + +[index.ts:48](https://github.com/lancedb/lancedb/blob/b1eeb90/node/src/index.ts#L48) diff --git a/node/src/index.ts b/node/src/index.ts index f8072799..0636cb95 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -142,7 +142,34 @@ export interface Table { /** * Delete rows from this table. * - * @param filter A filter in the same format used by a sql WHERE clause. + * This can be used to delete a single row, many rows, all rows, or + * sometimes no rows (if your predicate matches nothing). + * + * @param filter A filter in the same format used by a sql WHERE clause. The + * filter must not be empty. + * + * @examples + * + * ```ts + * const con = await lancedb.connect("./.lancedb") + * const data = [ + * {id: 1, vector: [1, 2]}, + * {id: 2, vector: [3, 4]}, + * {id: 3, vector: [5, 6]}, + * ]; + * const tbl = await con.createTable("my_table", data) + * await tbl.delete("id = 2") + * await tbl.countRows() // Returns 2 + * ``` + * + * If you have a list of values to delete, you can combine them into a + * stringified list and use the `IN` operator: + * + * ```ts + * const to_remove = [1, 5]; + * await tbl.delete(`id IN (${to_remove.join(",")})`) + * await tbl.countRows() // Returns 1 + * ``` */ delete: (filter: string) => Promise } diff --git a/python/lancedb/remote/table.py b/python/lancedb/remote/table.py index 3c7070a2..c4a4f2a7 100644 --- a/python/lancedb/remote/table.py +++ b/python/lancedb/remote/table.py @@ -89,3 +89,6 @@ class RemoteTable(Table): def _execute_query(self, query: Query) -> pa.Table: result = self._conn._client.query(self._name, query) return self._conn._loop.run_until_complete(result).to_arrow() + + def delete(self, predicate: str): + raise NotImplementedError diff --git a/python/lancedb/table.py b/python/lancedb/table.py index 8d7a3b50..d2fa3d0f 100644 --- a/python/lancedb/table.py +++ b/python/lancedb/table.py @@ -202,6 +202,51 @@ class Table(ABC): def _execute_query(self, query: Query) -> pa.Table: pass + @abstractmethod + def delete(self, where: str): + """Delete rows from the table. + + This can be used to delete a single row, many rows, all rows, or + sometimes no rows (if your predicate matches nothing). + + Parameters + ---------- + where: str + The SQL where clause to use when deleting rows. For example, 'x = 2' + or 'x IN (1, 2, 3)'. The filter must not be empty, or it will error. + + Examples + -------- + >>> import lancedb + >>> import pandas as pd + >>> data = pd.DataFrame({"x": [1, 2, 3], "vector": [[1, 2], [3, 4], [5, 6]]}) + >>> db = lancedb.connect("./.lancedb") + >>> table = db.create_table("my_table", data) + >>> table.to_pandas() + x vector + 0 1 [1.0, 2.0] + 1 2 [3.0, 4.0] + 2 3 [5.0, 6.0] + >>> table.delete("x = 2") + >>> table.to_pandas() + x vector + 0 1 [1.0, 2.0] + 1 3 [5.0, 6.0] + + If you have a list of values to delete, you can combine them into a + stringified list and use the `IN` operator: + + >>> to_remove = [1, 5] + >>> to_remove = ", ".join([str(v) for v in to_remove]) + >>> to_remove + '1, 5' + >>> table.delete(f"x IN ({to_remove})") + >>> table.to_pandas() + x vector + 0 3 [5.0, 6.0] + """ + raise NotImplementedError + class LanceTable(Table): """ @@ -496,31 +541,6 @@ class LanceTable(Table): return tbl def delete(self, where: str): - """Delete rows from the table. - - Parameters - ---------- - where: str - The SQL where clause to use when deleting rows. - - Examples - -------- - >>> import lancedb - >>> import pandas as pd - >>> data = pd.DataFrame({"x": [1, 2, 3], "vector": [[1, 2], [3, 4], [5, 6]]}) - >>> db = lancedb.connect("./.lancedb") - >>> table = db.create_table("my_table", data) - >>> table.to_pandas() - x vector - 0 1 [1.0, 2.0] - 1 2 [3.0, 4.0] - 2 3 [5.0, 6.0] - >>> table.delete("x = 2") - >>> table.to_pandas() - x vector - 0 1 [1.0, 2.0] - 1 3 [5.0, 6.0] - """ self._dataset.delete(where) def _execute_query(self, query: Query) -> pa.Table: