LanceDB-1.js
· 547 B · JavaScript
Eredeti
import * as lancedb from "@lancedb/lancedb";
const db = await lancedb.connect("data/sample-lancedb");
const table = await db.createTable("vectors", [
{ id: 1, vector: [0.1, 0.2], item: "foo", price: 10 },
{ id: 2, vector: [1.1, 1.2], item: "bar", price: 50 },
], {mode: 'overwrite'});
const query = table.vectorSearch([0.1, 0.3]).limit(2);
const results = await query.toArray();
// You can also search for rows by specific criteria without involving a vector search.
const rowsByCriteria = await table.query().where("price >= 10").toArray();
1 | import * as lancedb from "@lancedb/lancedb"; |
2 | |
3 | const db = await lancedb.connect("data/sample-lancedb"); |
4 | const table = await db.createTable("vectors", [ |
5 | { id: 1, vector: [0.1, 0.2], item: "foo", price: 10 }, |
6 | { id: 2, vector: [1.1, 1.2], item: "bar", price: 50 }, |
7 | ], {mode: 'overwrite'}); |
8 | |
9 | |
10 | const query = table.vectorSearch([0.1, 0.3]).limit(2); |
11 | const results = await query.toArray(); |
12 | |
13 | // You can also search for rows by specific criteria without involving a vector search. |
14 | const rowsByCriteria = await table.query().where("price >= 10").toArray(); |