Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.9: Add new retrieveVectors and _vectors behaviour #2876

Merged
merged 14 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 10 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1287,3 +1287,13 @@ analytics_event_bind_event_1: |-
"objectId": "0",
"position": 0
}'
search_parameter_reference_retrieve_vectors_1: |-
curl -X POST 'localhost:7700/indexes/INDEX_NAME/search' \
-H 'content-type: application/json' \
--data-binary '{
"q": "kitchen utensils",
"retrieveVectors": true,
"hybrid": {
"embedder": "default"
}
}'
39 changes: 39 additions & 0 deletions reference/api/documents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,45 @@ An array of documents. Each document is represented as a JSON object.
]
```

#### `_vectors`

`_vectors` is a special document attribute containing vector embeddings for AI-powered search. It accepts different types of values.

`_vectors` may be an array of numbers:
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

```json
[
{
"id": 452,
"title": "Female Trouble",
"overview": "Delinquent high school student Dawn Davenport runs away from home and embarks upon a life of crime.",
"_vectors": [0.0, 0.1, 0.003, 0.75]
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
},
]
```

`_vectors` may also be an object with two fields, `embeddings` and `regenerate`:
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

```json
[
{
"id": 452,
"title": "Female Trouble",
"overview": "Delinquent high school student Dawn Davenport runs away from home and embarks upon a life of crime.",
"_vectors": {
"embeddings": [],
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
"regenerate": true
}
}
]
```

`embeddings` must be an array of numbers.
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

`regenerate` must be a Boolean value. If `regenerate` is `true`, the supplied embeddings will be overwritten the next time Meilisearch automatically generates document embeddings. If `regenerate` is `false`, the document's embeddings will be automatically replaced by an embedder.
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

If `_vectors` is empty or `null`, Meilisearch treats the document as not having any embeddings. This document is then ignored during AI-powered searches.
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

### Example

<CodeSamples id="add_or_replace_documents_1" />
Expand Down
18 changes: 18 additions & 0 deletions reference/api/search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,10 @@ Meilisearch will return an error if you use `hybrid` before activating your inst

### Vector (experimental)

**Parameter**: `vector`<br />
**Expected value**: an array of numbers<br />
**Default value**: `null`

Use a custom vector to perform a search query. Must be an array of numbers corresponding to the dimensions of the custom vector.

`vector` is mandatory when performing searches with `userProvided` embedders. You may also use `vector` to override an embedder's automatic vector generation.
Expand All @@ -1118,3 +1122,17 @@ Use a custom vector to perform a search query. Must be an array of numbers corre
<Capsule intent="warning">
Meilisearch will return an error if you use `vector` before activating your instance's `vectorStore` and [configuring a custom embedder](/reference/api/settings#embedders-experimental).
</Capsule>

### Display `_vectors` in response (experimental)

**Parameter**: `retrieveVectors`<br />
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
**Expected value**: `true` or `false`<br />
**Default value**: `false`

Return document vector data in AI-powered searches.

This parameter has no effect on queries that do not include `vector` or `hybrid`.
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

#### Example

<CodeSamples id="search_parameter_reference_retrieve_vectors_1" />