doc: fix js example of create index (#886)

This commit is contained in:
Lei Xu
2024-01-28 17:02:36 -08:00
committed by GitHub
parent b9c5323265
commit e5796a4836
2 changed files with 19 additions and 3 deletions

View File

@@ -213,8 +213,7 @@ After a table has been created, you can always add more data to it using
=== "Typescript"
```typescript
await tbl.add([{vector: [1.3, 1.4], item: "fizz", price: 100.0},
{vector: [9.5, 56.2], item: "buzz", price: 200.0}])
--8<-- "docs/src/basic_legacy.ts:add"
```
=== "Rust"
@@ -261,7 +260,7 @@ For tables with more than 50K vectors, creating an ANN index is recommended to s
=== "Typescript"
```{.typescript .ignore}
await tbl.createIndex({})
--8<-- "docs/src/basic_legacy.ts:create_index"
```
=== "Rust"

View File

@@ -23,6 +23,23 @@ const example = async () => {
);
// --8<-- [end:create_table]
// --8<-- [start:add]
const newData = Array.from({ length: 500 }, (_, i) => ({
vector: [i, i + 1],
item: "fizz",
price: i * 0.1,
}));
await tbl.add(newData);
// --8<-- [end:add]
// --8<-- [start:create_index]
await tbl.createIndex({
type: "ivf_pq",
num_partitions: 2,
num_sub_vectors: 2,
});
// --8<-- [end:create_index]
// --8<-- [start:create_empty_table]
const schema = new Schema([
new Field("id", new Int32()),