mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-15 16:22:27 +00:00
The pages describing this code lived in lancedb/docs, a repository with ten stars that neither contributing guide mentioned. A user who hit a wrong page while reading the source had to find a separate, near-invisible repository to fix it. These 102 pages now sit beside the code, and a documentation fix is a pull request in the repository the reader already had open. `docs/web` is a complete Mintlify site: `cd docs/web && mint dev` serves it with no other checkout. Enterprise pages stay private and are merged in when the published site is assembled, so links into them do not resolve here — every open-source page does. `docs/web-tests` holds the tests the code examples are extracted from. They ran against a published wheel before; here they can run against this repository's own SDK, so an example that stops compiling fails the pull request that broke it rather than being noticed later. Both directories sit beside `docs/src` and are invisible to it: mkdocs reads `docs_dir: src`, so the SDK reference builds and deploys exactly as before.
7 lines
2.3 KiB
Plaintext
7 lines
2.3 KiB
Plaintext
{/* Auto-generated by scripts/mdx_snippets_gen.py. Do not edit manually. */}
|
|
|
|
export const RsCreateIndex = "// For this example, `table` is a lancedb::Table with a column named\n// \"vector\" that is a vector column with dimension 128.\n\n// By default, if the column \"vector\" appears to be a vector column,\n// then an IVF_PQ index with reasonable defaults is created.\ntable\n .create_index(&[\"vector\"], Index::Auto)\n .execute()\n .await?;\n// For advanced cases, it is also possible to specifically request an\n// IVF_PQ index and provide custom parameters.\ntable\n .create_index(\n &[\"vector\"],\n Index::IvfPq(\n // Here we specify advanced indexing parameters. In this case\n // we are creating an index that my have better recall than the\n // default but is also larger and slower.\n IvfPqIndexBuilder::default()\n // This overrides the default distance type of l2\n .distance_type(DistanceType::Cosine)\n // With 1000 rows this have been ~31 by default\n .num_partitions(50)\n // With dimension 128 this would have been 8 by default\n .num_sub_vectors(16),\n ),\n )\n .execute()\n .await?;\n";
|
|
|
|
export const RsSearch1 = "let query_vector = [1.0; 128];\n// By default the index will find the 10 closest results using default\n// search parameters that give a reasonable tradeoff between accuracy\n// and search latency\nlet mut results = table\n .vector_search(&query_vector)?\n // Note: you should always set the distance_type to match the value used\n // to train the index\n .distance_type(DistanceType::Cosine)\n .execute()\n .await?;\nwhile let Some(batch) = results.try_next().await? {\n println!(\"{:?}\", batch);\n}\n// We can also provide custom search parameters. Here we perform a\n// slower but more accurate search\nlet mut results = table\n .vector_search(&query_vector)?\n .distance_type(DistanceType::Cosine)\n // Override the default of 10 to get more rows\n .limit(15)\n // Override the default of 20 to search more partitions\n .nprobes(30)\n // Override the default of None to apply a refine step\n .refine_factor(1)\n .execute()\n .await?;\nwhile let Some(batch) = results.try_next().await? {\n println!(\"{:?}\", batch);\n}\nOk(())\n";
|
|
|