Skip to content

Commit c211cda

Browse files
add code samples, errors, update multi_search ref
1 parent 4d60c42 commit c211cda

File tree

4 files changed

+191
-31
lines changed

4 files changed

+191
-31
lines changed

.code-samples.meilisearch.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,3 +1444,42 @@ experimental_post_logs_stream_1: |-
14441444
experimental_delete_logs_stream_1: |-
14451445
curl \
14461446
-X DELETE MEILISEARCH_URL/logs/stream
1447+
multi_search_remote_federated_1: |-
1448+
curl \
1449+
-X POST 'MEILISEARCH_URL/multi-search' \
1450+
-H 'Content-Type: application/json' \
1451+
--data-binary '{
1452+
"federation": {},
1453+
"queries": [
1454+
{
1455+
"indexUid": "movies",
1456+
"q": "batman",
1457+
"remote": "ms-00"
1458+
},
1459+
{
1460+
"indexUid": "movies",
1461+
"q": "batman",
1462+
"remote": "ms-01"
1463+
}
1464+
]
1465+
}'
1466+
get_network_1: |-
1467+
curl \
1468+
-X GET 'MEILISEARCH_URL/network'
1469+
update_network_1: |-
1470+
curl \
1471+
-X PATCH 'MEILISEARCH_URL/network' \
1472+
-H 'Content-Type: application/json' \
1473+
--data-binary '{
1474+
"self": "ms-00",
1475+
"remotes": {
1476+
"ms-00": {
1477+
"url": "http://INSTANCE_URL",
1478+
"searchApiKey": "INSTANCE_API_KEY"
1479+
},
1480+
"ms-01": {
1481+
"url": "http://ANOTHER_INSTANCE_URL",
1482+
"searchApiKey": "ANOTHER_INSTANCE_API_KEY"
1483+
}
1484+
}
1485+
}'

reference/api/multi_search.mdx

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ There is no way to specify that two documents should be treated as the same acro
139139

140140
| Search parameter | Type | Default value | Description |
141141
| :--------------------------------------------------------------------------- | :--------------- | :------------ | :-------------------------------------------------- |
142-
| **[`federationOptions`](#federationoptions)** | Object | `null` | Configure federation settings for a specific query |
143-
| **[`indexUid`](/learn/getting_started/indexes#index-uid)** | String | N/A | `uid` of the requested index |
142+
| **[`federationOptions`](#federationoptions)** | Object | `null` | Configure federation settings for a specific query |
143+
| **[`indexUid`](/learn/getting_started/indexes#index-uid)** | String | N/A | `uid` of the requested index |
144144
| **[`q`](/reference/api/search#query-q)** | String | `""` | Query string |
145145
| **[`offset`](/reference/api/search#offset)** | Integer | `0` | Number of documents to skip |
146146
| **[`limit`](/reference/api/search#limit)** | Integer | `20` | Maximum number of documents returned |
147147
| **[`hitsPerPage`](/reference/api/search#number-of-results-per-page)** | Integer | `1` | Maximum number of documents returned for a page |
148148
| **[`page`](/reference/api/search#page)** | Integer | `1` | Request a specific page of results |
149-
| **[`filter`](/reference/api/search#filter)** | [String](/learn/filtering_and_sorting/filter_expression_reference) | `null` | Filter queries by an attribute's value |
149+
| **[`filter`](/reference/api/search#filter)** | String | `null` | Filter queries by an attribute's value |
150150
| **[`facets`](/reference/api/search#facets)** | Array of strings | `null` | Display the count of matches per facet |
151151
| **[`attributesToRetrieve`](/reference/api/search#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents |
152152
| **[`attributesToCrop`](/reference/api/search#attributes-to-crop)** | Array of strings | `null` | Attributes whose values have to be cropped |
@@ -172,10 +172,11 @@ These options are not compatible with federated searches.
172172
`federationOptions` must be an object. It accepts the following parameters:
173173

174174
- `weight`: serves as a multiplicative factor to ranking scores of search results in this specific query. If < `1.0`, the hits from this query are less likely to appear in the final results list. If > `1.0`, the hits from this query are more likely to appear in the final results list. Must be a positive floating-point number. Defaults to `1.0`
175+
- `remote` <NoticeTag type="experimental" label="experimental" />: indicates the remote instance where Meilisearch will perform the query. Must be a string corresponding to a [remote object](/reference/api/network). Defaults to `null`
175176

176177
### Response
177178

178-
The response to `/multi-search` queries may take two shapes: federated and non-federated.
179+
The response to `/multi-search` queries may take different shapes depending on the type of query you're making.
179180

180181
#### Non-federated multi-search requests
181182

@@ -187,7 +188,7 @@ Each search result object is composed of the following fields:
187188

188189
| Name | Type | Description |
189190
| :----------------------- | :--------------- | :------------------------------------------------------------------------------- |
190-
| **`indexUid`** | String | [`uid`](/learn/getting_started/indexes#index-uid) of the requested index |
191+
| **`indexUid`** | String | [`uid`](/learn/getting_started/indexes#index-uid) of the requested index |
191192
| **`hits`** | Array of objects | Results of the query |
192193
| **`offset`** | Number | Number of documents skipped |
193194
| **`limit`** | Number | Number of documents to take |
@@ -212,24 +213,27 @@ Federated search requests return a single object and the following fields:
212213
| **`limit`** | Number | Number of documents to take |
213214
| **`estimatedTotalHits`** | Number | Estimated total number of matches |
214215
| **`processingTimeMs`** | Number | Processing time of the query |
215-
| **`facetsByIndex`** | Object | [Data for facets present in the search results](#facetsbyindex) |
216-
| **`facetDistribution`** | Object | [Distribution of the given facets](#mergefacets) |
217-
| **`facetStats`** | Object | [The numeric `min` and `max` values per facet](#mergefacets) |
216+
| **`facetsByIndex`** | Object | [Data for facets present in the search results](#facetsbyindex) |
217+
| **`facetDistribution`** | Object | [Distribution of the given facets](#mergefacets) |
218+
| **`facetStats`** | Object | [The numeric `min` and `max` values per facet](#mergefacets) |
219+
| **`remoteErrors`** | Object | Indicates which remote requests failed and why |
218220

219221
Each result in the `hits` array contains an additional `_federation` field with the following fields:
220222

221-
| Name | Type | Description |
222-
| :----------------------- | :--------------- | :------------------------------------------------------------------------------- |
223-
| **`indexUid`** | String | Index of origin for this document |
224-
| **`queriesPosition`** | Number | Array index number of the query in the request's `queries` array |
223+
| Name | Type | Description |
224+
| :-------------------------- | :--------------- | :--------------------------------------------------------------------------------- |
225+
| **`indexUid`** | String | Index of origin for this document |
226+
| **`queriesPosition`** | Number | Array index number of the query in the request's `queries` array |
227+
| **`remote`** | String | String indicating the queried remote instance |
228+
| **`weightedRankingScore`** | Number | The product of the _rankingScore of the hit and the weight of the query of origin. |
225229

226230
### Example
227231

228232
#### Non-federated multi-search
229233

230234
<CodeSamples id="multi_search_1" />
231235

232-
#### Response: `200 Ok`
236+
##### Response: `200 Ok`
233237

234238
```json
235239
{
@@ -289,7 +293,7 @@ Each result in the `hits` array contains an additional `_federation` field with
289293

290294
<CodeSamples id="multi_search_federated_1" />
291295

292-
#### Response: `200 Ok`
296+
##### Response: `200 Ok`
293297

294298
```json
295299
{
@@ -321,3 +325,51 @@ Each result in the `hits` array contains an additional `_federation` field with
321325
"semanticHitCount": 0
322326
}
323327
```
328+
329+
#### Remote federated multi-search <NoticeTag type="experimental" label="experimental" />
330+
331+
<CodeSamples id="multi_search_remote_federated_1" />
332+
333+
##### Response: `200 Ok`
334+
335+
```json
336+
{
337+
"hits": [
338+
{
339+
"id": 42,
340+
"title": "Batman returns",
341+
"overview": …,
342+
"_federation": {
343+
"indexUid": "movies",
344+
"queriesPosition": 0,
345+
"weightedRankingScore": 1.0,
346+
"remote": "ms-01"
347+
}
348+
},
349+
{
350+
"id": 87,
351+
"description": …,
352+
"title": "Batman: the killing joke",
353+
"_federation": {
354+
"indexUid": "movies",
355+
"queriesPosition": 1,
356+
"weightedRankingScore": 0.9848484848484849,
357+
"remote": "ms-00"
358+
}
359+
},
360+
361+
],
362+
"processingTimeMs": 35,
363+
"limit": 5,
364+
"offset": 0,
365+
"estimatedTotalHits": 111,
366+
"remoteErrors": {
367+
"ms-02": {
368+
"message": "error sending request",
369+
"code": "proxy_could_not_send_request",
370+
"type": "system",
371+
"link": "https://docs.meilisearch.com/errors#proxy_could_not_make_request"
372+
}
373+
}
374+
}
375+
```

reference/api/network.mdx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ This feature is not available for Meilisearch Cloud users.
5252
**Default value**: `{}`<br />
5353
**Description**: An object containing `remote` objects. The key of each remote object indicates the name of the remote instance
5454

55-
### The remote object
55+
#### The remote object
5656

5757
```json
5858
"ms-00": {
@@ -61,15 +61,15 @@ This feature is not available for Meilisearch Cloud users.
6161
}
6262
```
6363

64-
### `url`
64+
##### `url`
6565

6666
**Type**: String<br />
6767
**Default value**: `null`<br />
6868
**Description**: URL indicating the address of a Meilisearch instance. This URL does not need to be public, but must be accessible to all instances in the network. Required.
6969

70-
### `searchApiKey`
70+
##### `searchApiKey`
7171

72-
**Type**: Stringf<br />
72+
**Type**: String<br />
7373
**Default value**: `null`<br />
7474
**Description**: An API key with search permissions
7575

@@ -109,7 +109,7 @@ Update the `self` and `remotes` fields of the network object.
109109

110110
Updates to the network object are **partial**. Only provide the fields you intend to update. Fields not present in the payload will remain unchanged.
111111

112-
To reset `self` and `remotes` to their original value, set them to `null`. To remov a single `remote` from your network, set the value of its name to `null`.
112+
To reset `self` and `remotes` to their original value, set them to `null`. To remove a single `remote` from your network, set the value of its name to `null`.
113113

114114
### Body
115115

@@ -125,6 +125,17 @@ To reset `self` and `remotes` to their original value, set them to `null`. To re
125125
#### Response: `200 Ok`
126126

127127
```json
128-
128+
{
129+
"self": "ms-00",
130+
"remotes": {
131+
"ms-00": {
132+
"url": "http://INSTANCE_URL",
133+
"searchApiKey": "INSTANCE_API_KEY"
134+
},
135+
"ms-01": {
136+
"url": "http://ANOTHER_INSTANCE_URL",
137+
"searchApiKey": "ANOTHER_INSTANCE_API_KEY"
138+
}
139+
}
140+
}
129141
```
130-

reference/errors/error_codes.mdx

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ An error occurred during the dump creation process. The task was aborted.
4343

4444
The [`/facet-search`](/reference/api/facet_search) route has been queried while [the `facetSearch` index setting](/reference/api/settings#facet-search) is set to `false`.
4545

46+
## `feature_not_enabled`
47+
48+
Trying to perform one of the actions guarded by `proxy_search` without enabling that feature first. Find the list above: [New experimental feature `proxySearch`](https://www.notion.so/New-experimental-feature-proxySearch-1894b06b651f809997abd5d66440cfc6?pvs=21)
49+
4650
## `immutable_api_key_actions`
4751

4852
The [`actions`](/reference/api/keys#actions) field of an API key cannot be modified.
@@ -213,6 +217,10 @@ A multi-search query includes `federationOptions` but the top-level `federation`
213217

214218
A multi-search query contains `page`, `hitsPerPage`, `limit` or `offset`, but the top-level federation object is not `null`.
215219

220+
## `invalid_multi_search_query_position`
221+
222+
`federationOptions.queryPosition` is not a positive integer.
223+
216224
## `invalid_multi_search_weight`
217225

218226
A multi-search query contains a negative value for `federated.weight`.
@@ -249,6 +257,26 @@ Two or more indexes have a different `faceting.sortFacetValuesBy` for the same r
249257

250258
`facetsByIndex` is not an object or contains unknown fields.
251259

260+
## `invalid_multi_search_remote`
261+
262+
`federationOptions.remote` is not `network.self` and is not a key in `network.remotes`.
263+
264+
## `invalid_network_self`
265+
266+
The [network object](/reference/api/network#the-network-object) contains a `self` that is not a string or `null`.
267+
268+
## `invalid_network_remotes`
269+
270+
The [network object](/reference/api/network#the-network-object) contains a `remotes` that is not an object or `null`.
271+
272+
## `invalid_network_url`
273+
274+
One of the remotes in the [network object](/reference/api/network#the-network-object) contains a `url` that is not a string.
275+
276+
## `invalid_network_search_api_key`
277+
278+
One of the remotes in the [network object](/reference/api/network#the-network-object) contains a `searchApiKey` that is not a string or `null`.
279+
252280
## `invalid_search_attributes_to_crop`
253281

254282
The [`attributesToCrop`](/reference/api/search#attributes-to-crop) parameter is invalid. It should be an array of strings, a string, or set to `null`.
@@ -411,41 +439,41 @@ This error occurs if:
411439
- The [`minWordSizeForTypos`](/reference/api/settings#typo-tolerance-object) field is invalid. It should either be an integer or set to `null`
412440
- The value of either [`oneTypo`](/reference/api/settings#typo-tolerance-object) or [`twoTypos`](/reference/api/settings#typo-tolerance-object) is invalid. It should either be an integer or set to `null`
413441

414-
### `invalid_similar_id`
442+
## `invalid_similar_id`
415443

416444
The provided target document identifier is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_).
417445

418-
### `not_found_similar_id`
446+
## `not_found_similar_id`
419447

420448
Meilisearch could not find the target document. Make sure your target document identifier corresponds to a document in your index.
421449

422-
### `invalid_similar_attributes_to_retrieve`
450+
## `invalid_similar_attributes_to_retrieve`
423451

424452
[`attributesToRetrieve`](/reference/api/search#attributes-to-retrieve) is invalid. It should be an array of strings, a string, or set to null.
425453

426-
### `invalid_similar_filter`
454+
## `invalid_similar_filter`
427455

428456
[`filter`](/reference/api/search#filter) is invalid or contains a filter expression with a missing or invalid operator. Filter expressions must be a string, array of strings, or array of array of strings for the POST endpoint. It must be a string for the GET endpoint.
429457

430458
Meilisearch also throws this error if the attribute used for filtering is not defined in the `filterableAttributes` list.
431459

432-
### `invalid_similar_limit`
460+
## `invalid_similar_limit`
433461

434462
[`limit`](/reference/api/search#limit) is invalid. It should be an integer.
435463

436-
### `invalid_similar_offset`
464+
## `invalid_similar_offset`
437465

438466
[`offset`](/reference/api/search#offset) is invalid. It should be an integer.
439467

440-
### `invalid_similar_show_ranking_score`
468+
## `invalid_similar_show_ranking_score`
441469

442470
[`ranking_score`](/reference/api/search#ranking-score) is invalid. It should be a boolean.
443471

444-
### `invalid_similar_show_ranking_score_details`
472+
## `invalid_similar_show_ranking_score_details`
445473

446474
[`ranking_score_details`](/reference/api/search#ranking-score-details) is invalid. It should be a boolean.
447475

448-
### `invalid_embedder`
476+
## `invalid_embedder`
449477

450478
[`embedder`](/reference/api/search#hybrid-search-experimental) is invalid. It should be a string corresponding to the name of a configured embedder.
451479

@@ -575,6 +603,10 @@ The [`facetName`](/reference/api/facet_search#body) parameter is required.
575603

576604
You need to set a master key before you can access the `/keys` route. Read more about setting a master key at launch in our [security tutorial](/learn/security/basic_security).
577605

606+
## `missing_network_url`
607+
608+
One of the remotes in the [network object](/reference/api/network#the-network-object) does not contain the `url` field.
609+
578610
## `missing_payload`
579611

580612
The Content-Type header was specified, but no request body was sent to the server or the request body is empty.
@@ -618,6 +650,32 @@ You have reached the limit of concurrent search requests. You may configure it b
618650

619651
The document exists in store, but there was an error retrieving it. This probably comes from an inconsistent state in the database.
620652

621-
### `vector_embedding_error`
653+
## `vector_embedding_error`
622654

623655
Error while generating embeddings.
656+
657+
## Remote federated search errors
658+
659+
### `remote_bad_response`
660+
661+
The remote instance answered with a response that this instance could not use as a federated search response.
662+
663+
### `remote_bad_request`
664+
665+
The remote instance answered with `400 BAD REQUEST`.
666+
667+
### `remote_could_not_send_request`
668+
669+
There was an error while sending the remote federated search request.
670+
671+
### `remote_invalid_api_key`
672+
673+
The remote instance answered with `403 FORBIDDEN` or `401 UNAUTHORIZED` to this instance’s request. The configured search API key is either missing, invalid, or lacks the required search permission.
674+
675+
### `remote_remote_error`
676+
677+
The remote instance answered with `500 INTERNAL ERROR`.
678+
679+
### `remote_timeout`
680+
681+
The proxy did not answer in the allocated time.

0 commit comments

Comments
 (0)