Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/content/docs/vectorize/best-practices/query-vectors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/content/docs/vectorize/get-started/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ export default {
} satisfies ExportedHandler<Env>;
```

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:
Expand Down
18 changes: 18 additions & 0 deletions src/content/docs/vectorize/reference/client-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/content/docs/workers/wrangler/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ wrangler docs [<COMMAND>]

## `init`

:::note

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning was removed in #17844 - this should not have been reverted in this unrelated PR. @garvit-gupta @Oxyjun

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @emily-shen, I think this change was included when this branch was updated with main. I can remove that warning if you think that would be the appropriate next step.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey yeah if you would be able to remove it again that would be great, thanks!

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
Expand Down Expand Up @@ -591,8 +597,10 @@ npx wrangler vectorize query <INDEX_NAME> [OPTIONS]

- `INDEX_NAME` <Type text="string" /> <MetaInfo text="required" />
- The name of the Vectorize index to query.
- `--vector` <Type text="array" /> <MetaInfo text="required" />
- Vector against which the Vectorize index is queried.
- `--vector` <Type text="array" /> <MetaInfo text="optional" />
- Vector against which the Vectorize index is queried. Either this or the `vector-id` param must be provided.
- `--vector-id` <Type text="string" /> <MetaInfo text="optional" />
- 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` <Type text="number" /> <MetaInfo text="optional" />
- The number of vectors to query (default: `5`).
- `--return-values` <Type text="boolean" /> <MetaInfo text="optional" />
Expand Down
Loading