Skip to content

Commit 191aaa6

Browse files
v1.12: prefixSearch and facetSearch index settings (#3070)
1 parent bc4eb35 commit 191aaa6

File tree

3 files changed

+238
-1
lines changed

3 files changed

+238
-1
lines changed

.code-samples.meilisearch.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,28 @@ update_proximity_precision_settings_1: |-
12011201
reset_proximity_precision_settings_1: |-
12021202
curl \
12031203
-X DELETE 'http://localhost:7700/indexes/books/settings/proximity-precision'
1204+
get_facet_search_settings_1: |-
1205+
curl \
1206+
-X GET 'http://localhost:7700/indexes/INDEX_UID/settings/facet-search'
1207+
update_facet_search_settings_1: |-
1208+
curl \
1209+
-X PUT 'http://localhost:7700/indexes/INDEX_UID/settings/facet-search' \
1210+
-H 'Content-Type: application/json' \
1211+
--data-binary 'false'
1212+
reset_facet_search_settings_1: |-
1213+
curl \
1214+
-X DELETE 'http://localhost:7700/indexes/INDEX_UID/settings/facet-search'
1215+
get_prefix_search_settings_1: |-
1216+
curl \
1217+
-X GET 'http://localhost:7700/indexes/INDEX_UID/settings/prefix-search'
1218+
update_prefix_search_settings_1: |-
1219+
curl \
1220+
-X PUT 'http://localhost:7700/indexes/INDEX_UID/settings/prefix-search' \
1221+
-H 'Content-Type: application/json' \
1222+
--data-binary '"disabled"'
1223+
reset_prefix_search_settings_1: |-
1224+
curl \
1225+
-X DELETE 'http://localhost:7700/indexes/INDEX_UID/settings/prefix-search'
12041226
index_settings_tutorial_api_get_setting_1: |-
12051227
curl \
12061228
-X GET 'http://localhost:7700/indexes/INDEX_NAME/settings/searchable-attributes'

reference/api/settings.mdx

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ By default, the settings object looks like this. All fields are modifiable.
5959
"maxTotalHits": 1000
6060
},
6161
"proximityPrecision": "byWord",
62+
"facetSearch": true,
63+
"prefixSearch": "indexingTime",
6264
"searchCutoffMs": null
6365
}
6466
```
@@ -126,6 +128,8 @@ Get the settings of an index.
126128
"maxTotalHits": 1000
127129
},
128130
"proximityPrecision": "byWord",
131+
"facetSearch": true,
132+
"prefixSearch": "indexingTime",
129133
"searchCutoffMs": null
130134
}
131135
```
@@ -159,6 +163,8 @@ If the provided index does not exist, it will be created.
159163
| **[`filterableAttributes`](#filterable-attributes)** | Array of strings | Empty | Attributes to use as filters and facets |
160164
| **[`pagination`](#pagination)** | Object | [Default object](#pagination-object) | Pagination settings |
161165
| **[`proximityPrecision`](#proximity-precision)** | String | `"byWord"` | Precision level when calculating the proximity ranking rule |
166+
| **[`facetSearch`](#facet-search)** | Boolean | `true` | Enable or disable [facet search](/reference/api/facet_search) functionality |
167+
| **[`prefixSearch`](#prefix-search)** | String | `"indexingTime"` | When Meilisearch should return results only matching the beginning of query |
162168
| **[`rankingRules`](#ranking-rules)** | Array of strings | `["words",`<br />`"typo",`<br />`"proximity",`<br />`"attribute",`<br />`"sort",`<br />`"exactness"]` | List of ranking rules in order of importance |
163169
| **[`searchableAttributes`](#searchable-attributes)** | Array of strings | All attributes: `["*"]` | Fields in which to search for matching query words sorted by order of importance |
164170
| **[`searchCutoffMs`](#search-cutoff)** | Integer | `null`, or 1500ms | Maximum duration of a search query |
@@ -1115,6 +1121,8 @@ You can use the returned `taskUid` to get more details on [the status of the tas
11151121

11161122
### Reset proximity precision settings
11171123

1124+
<RouteHighlighter method="DELETE" route="/indexes/{index_uid}/settings/proximity-precision"/>
1125+
11181126
Reset an index's proximity precision setting to its default value.
11191127

11201128
#### Path parameters
@@ -1141,6 +1149,201 @@ Reset an index's proximity precision setting to its default value.
11411149

11421150
You can use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks#get-one-task).
11431151

1152+
## Facet search
1153+
1154+
Processing filterable attributes for facet search is a resource-intensive operation. This feature is enabled by default, but disabling it may speed up indexing.
1155+
1156+
`facetSearch` accepts a single Boolean value. If set to `false`, it disables facet search for the whole index. Meilisearch returns an error if you try to access the `/facet-search` endpoint when facet search is disabled.
1157+
1158+
### Get facet search settings
1159+
1160+
<RouteHighlighter method="GET" route="/indexes/{index_uid}/settings/facet-search"/>
1161+
1162+
Get the facet search settings of an index.
1163+
1164+
#### Path parameters
1165+
1166+
| Name | Type | Description |
1167+
| :---------------- | :----- | :--------------------------------------------------------------------- |
1168+
| **`index_uid`** * | String | [`uid`](/learn/getting_started/indexes#index-uid) of the requested index |
1169+
1170+
#### Example
1171+
1172+
<CodeSamples id="get_facet_search_settings_1" />
1173+
1174+
##### Response: `200 OK`
1175+
1176+
```json
1177+
{
1178+
"facetSearch": true
1179+
}
1180+
```
1181+
1182+
### Update facet search settings
1183+
1184+
<RouteHighlighter method="PUT" route="/indexes/{index_uid}/settings/facet-search"/>
1185+
1186+
Update the facet search settings for an index.
1187+
1188+
#### Path parameters
1189+
1190+
| Name | Type | Description |
1191+
| :---------------- | :----- | :--------------------------------------------------------------------- |
1192+
| **`index_uid`** * | String | [`uid`](/learn/getting_started/indexes#index-uid) of the requested index |
1193+
1194+
#### Body
1195+
1196+
```
1197+
<Boolean>
1198+
```
1199+
1200+
#### Example
1201+
1202+
<CodeSamples id="update_facet_search_settings_1" />
1203+
1204+
##### Response: `202 Accepted`
1205+
1206+
```json
1207+
{
1208+
"taskUid": 1,
1209+
"indexUid": "INDEX_UID",
1210+
"status": "enqueued",
1211+
"type": "settingsUpdate",
1212+
"enqueuedAt": "2024-07-19T22:33:18.523881Z"
1213+
}
1214+
```
1215+
1216+
Use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks#get-one-task).
1217+
1218+
### Reset facet search settings
1219+
1220+
<RouteHighlighter method="DELETE" route="/indexes/{index_uid}/settings/facet-search"/>
1221+
1222+
Reset an index's facet search to its default settings.
1223+
1224+
#### Path parameters
1225+
1226+
| Name | Type | Description |
1227+
| :---------------- | :----- | :--------------------------------------------------------------------- |
1228+
| **`index_uid`** * | String | [`uid`](/learn/getting_started/indexes#index-uid) of the requested index |
1229+
1230+
#### Example
1231+
1232+
<CodeSamples id="reset_facet_search_settings_1" />
1233+
1234+
##### Response: `202 Accepted`
1235+
1236+
```json
1237+
{
1238+
"taskUid": 1,
1239+
"indexUid": "INDEX_UID",
1240+
"status": "enqueued",
1241+
"type": "settingsUpdate",
1242+
"enqueuedAt": "2024-07-19T22:35:33.723983Z"
1243+
}
1244+
```
1245+
1246+
Use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks#get-one-task).
1247+
1248+
## Prefix search
1249+
1250+
Prefix search is the process through which Meilisearch matches documents that begin with a specific query term, instead of only exact matches. This is a resource-intensive operation that happens during indexing by default.
1251+
1252+
Use `prefixSearch` to change how prefix search works. It accepts one of the following strings:
1253+
1254+
- `"indexingTime"`: calculate prefix search during indexing. This is the default behavior
1255+
- `"disabled"`: do not calculate prefix search. May speed up indexing, but will severely impact search result relevancy
1256+
1257+
### Get prefix search settings
1258+
1259+
<RouteHighlighter method="GET" route="/indexes/{index_uid}/settings/prefix-search"/>
1260+
1261+
Get the prefix search settings of an index.
1262+
1263+
#### Path parameters
1264+
1265+
| Name | Type | Description |
1266+
| :---------------- | :----- | :--------------------------------------------------------------------- |
1267+
| **`index_uid`** * | String | [`uid`](/learn/getting_started/indexes#index-uid) of the requested index |
1268+
1269+
#### Example
1270+
1271+
<CodeSamples id="get_prefix_search_settings_1" />
1272+
1273+
##### Response: `200 OK`
1274+
1275+
```json
1276+
{
1277+
"prefixSearch": "indexingTime"
1278+
}
1279+
```
1280+
1281+
### Update prefix search settings
1282+
1283+
<RouteHighlighter method="PUT" route="/indexes/{index_uid}/settings/prefix-search"/>
1284+
1285+
Update the prefix search settings for an index.
1286+
1287+
#### Path parameters
1288+
1289+
| Name | Type | Description |
1290+
| :---------------- | :----- | :--------------------------------------------------------------------- |
1291+
| **`index_uid`** * | String | [`uid`](/learn/getting_started/indexes#index-uid) of the requested index |
1292+
1293+
#### Body
1294+
1295+
```
1296+
"indexingTime" | "disabled"
1297+
```
1298+
1299+
#### Example
1300+
1301+
<CodeSamples id="update_prefix_search_settings_1" />
1302+
1303+
##### Response: `202 Accepted`
1304+
1305+
```json
1306+
{
1307+
"taskUid": 1,
1308+
"indexUid": "INDEX_UID",
1309+
"status": "enqueued",
1310+
"type": "settingsUpdate",
1311+
"enqueuedAt": "2024-07-19T22:33:18.523881Z"
1312+
}
1313+
```
1314+
1315+
Use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks#get-one-task).
1316+
1317+
### Reset prefix search settings
1318+
1319+
<RouteHighlighter method="DELETE" route="/indexes/{index_uid}/settings/prefix-search"/>
1320+
1321+
Reset an index's prefix search to its default settings.
1322+
1323+
#### Path parameters
1324+
1325+
| Name | Type | Description |
1326+
| :---------------- | :----- | :--------------------------------------------------------------------- |
1327+
| **`index_uid`** * | String | [`uid`](/learn/getting_started/indexes#index-uid) of the requested index |
1328+
1329+
#### Example
1330+
1331+
<CodeSamples id="reset_facet_search_settings_1" />
1332+
1333+
##### Response: `202 Accepted`
1334+
1335+
```json
1336+
{
1337+
"taskUid": 1,
1338+
"indexUid": "INDEX_UID",
1339+
"status": "enqueued",
1340+
"type": "settingsUpdate",
1341+
"enqueuedAt": "2024-07-19T22:35:33.723983Z"
1342+
}
1343+
```
1344+
1345+
Use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks#get-one-task).
1346+
11441347
## Ranking rules
11451348

11461349
Ranking rules are built-in rules that rank search results according to certain criteria. They are applied in the same order in which they appear in the `rankingRules` array.

reference/errors/error_codes.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ The requested document can't be retrieved. Either it doesn't exist, or the datab
3535

3636
An error occurred during the dump creation process. The task was aborted.
3737

38+
## `facet_search_disabled`
39+
40+
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`.
41+
3842
## `immutable_api_key_actions`
3943

4044
The [`actions`](/reference/api/keys#actions) field of an API key cannot be modified.
@@ -93,7 +97,7 @@ The requested index already has a primary key that [cannot be changed](/learn/ge
9397

9498
## `internal`
9599

96-
Meilisearch experienced an internal error. Check the error message, and [open an issue](https://github.com/meilisearch/meilisearch/issues/new?assignees=&labels=&template=bug_report&title=) if necessary.
100+
Meilisearch experienced an internal error. Check the error message, and [open an issue](https://github.com/meilisearch/meilisearch/issues/new?assignees=&labels=&template=bug_report&title=) if necessary.
97101

98102
## `invalid_api_key`
99103

@@ -296,6 +300,10 @@ The [`limit`](/reference/api/search#limit) parameter is invalid. It should be an
296300

297301
The [`locales`](/reference/api/search#query-locales) parameter is invalid.
298302

303+
## `invalid_settings_facet_search`
304+
305+
The [`facetSearch`](/reference/api/settings#facet-search) index setting value is invalid.
306+
299307
## `invalid_settings_localized_attributes`
300308

301309
The [`localizedAttributes`](/reference/api/settings#localized-attributes) index setting value is invalid.
@@ -308,6 +316,10 @@ The [`matchingStrategy`](/reference/api/search#matching-strategy) parameter is i
308316

309317
The [`offset`](/reference/api/search#offset) parameter is invalid. It should be an integer.
310318

319+
## `invalid_settings_prefix_search`
320+
321+
The [`prefixSearch`](/reference/api/settings#prefix-search) index setting value is invalid.
322+
311323
## `invalid_search_page`
312324

313325
The [`page`](/reference/api/search#page) parameter is invalid. It should be an integer.

0 commit comments

Comments
 (0)