diff --git a/src/content/docs/vectorize/best-practices/query-vectors.mdx b/src/content/docs/vectorize/best-practices/query-vectors.mdx index 11599965553d6c1..a45c80be1ec8ea9 100644 --- a/src/content/docs/vectorize/best-practices/query-vectors.mdx +++ b/src/content/docs/vectorize/best-practices/query-vectors.mdx @@ -67,6 +67,15 @@ This would return a set of matches resembling the following, based on the distan Refer to [Vectorize API](/vectorize/reference/client-api/) for additional examples. +## Query by vector identifier + +Vectorize now offers the ability to search for vectors similar to a vector that is already present in the index using the `queryById()` operation. This can be considered as a single operation that combines the `getById()` and the `query()` operation. + +```ts +// the query operation would yield results if a vector with id `some-vector-id` is already present in the index. +let matches = await env.YOUR_INDEX.queryById("some-vector-id"); +``` + ## Control over scoring precision and query accuracy When querying vectors, you can specify to either use high-precision scoring, thereby increasing the precision of the query matches scores as well as the accuracy of the query results, or use approximate scoring for faster response times. diff --git a/src/content/docs/vectorize/get-started/intro.mdx b/src/content/docs/vectorize/get-started/intro.mdx index f92c27ef7342781..e49b7823a7efa5b 100644 --- a/src/content/docs/vectorize/get-started/intro.mdx +++ b/src/content/docs/vectorize/get-started/intro.mdx @@ -395,6 +395,8 @@ export default { } satisfies ExportedHandler; ``` +You can also use the Vectorize `queryById()` operation to search for vectors similar to a vector that is already present in the index. + ## 7. Deploy your Worker Before deploying your Worker globally, log in with your Cloudflare account by running: diff --git a/src/content/docs/vectorize/reference/client-api.mdx b/src/content/docs/vectorize/reference/client-api.mdx index f0706c5ed4f40b9..d15857b26c8f8f7 100644 --- a/src/content/docs/vectorize/reference/client-api.mdx +++ b/src/content/docs/vectorize/reference/client-api.mdx @@ -83,6 +83,24 @@ For legacy Vectorize (V1) indexes, `topK` is limited to 20, and the `returnMetad ::: +### Query vectors by ID + +```ts +let matches = await env.YOUR_INDEX.queryById("some-vector-id"); +``` + +Query an index using a vector that is already present in the index. + +Query options remain the same as the query operation described above. + +```ts +let matches = await env.YOUR_INDEX.queryById("some-vector-id", { + topK: 5, + returnValues: true, + returnMetadata: "all", +}); +``` + ### Get vectors by ID ```ts diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index f491c1fc6509a3c..eb32f8959dd905c 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -139,6 +139,12 @@ wrangler docs [] ## `init` +:::note + +The `init` command will be removed in a future version. Please use `npm create cloudflare@latest` instead. + +::: + Create a new project via the [create-cloudflare-cli (C3) tool](/workers/get-started/guide/#1-create-a-new-worker-project). A variety of web frameworks are available to choose from as well as templates. Dependencies are installed by default, with the option to deploy your project immediately. ```txt @@ -591,8 +597,10 @@ npx wrangler vectorize query [OPTIONS] - `INDEX_NAME` - The name of the Vectorize index to query. -- `--vector` - - Vector against which the Vectorize index is queried. +- `--vector` + - Vector against which the Vectorize index is queried. Either this or the `vector-id` param must be provided. +- `--vector-id` + - Identifier for a vector that is already present in the index against which the index is queried. Either this or the `vector` param must be provided. - `--top-k` - The number of vectors to query (default: `5`). - `--return-values`