Skip to content

Commit 6ddbc50

Browse files
meili-bors[bot]meili-botatoulmetmdubuscurquiza
authored
Merge #1573
1573: Changes related to the next Meilisearch release (v1.4.0) r=curquiza a=meili-bot Related to this issue: meilisearch/integration-guides#286 This PR: - gathers the changes related to the next Meilisearch release (v1.4.0) so that this package is ready when the official release is out. - should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases). - might eventually contain test failures until the Meilisearch v1.4.0 is out. ⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.4.0) is out. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._ Co-authored-by: meili-bot <[email protected]> Co-authored-by: Alexia Toulmet <[email protected]> Co-authored-by: Morgane Dubus <[email protected]> Co-authored-by: Clémentine U. - curqui <[email protected]>
2 parents b66fa3a + dd8757a commit 6ddbc50

11 files changed

+691
-1
lines changed

.code-samples.meilisearch.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,28 @@ update_faceting_settings_1: |-
606606
})
607607
reset_faceting_settings_1: |-
608608
client.index('books').resetFaceting()
609+
get_dictionary_1: |-
610+
client.index('books').getDictionary()
611+
update_dictionary_1: |-
612+
client.index('books').updateDictionary(['J. R. R.', 'W. E. B.'])
613+
reset_dictionary_1: |-
614+
client.index('books').resetDictionary()
609615
search_parameter_guide_sort_1: |-
610616
client.index('books').search('science fiction', {
611617
sort: ['price:asc'],
612618
})
619+
get_separator_tokens_1: |-
620+
client.index('books').getSeparatorTokens()
621+
update_separator_tokens_1: |-
622+
client.index('books').updateSeparatorTokens(['|', '&hellip;'])
623+
reset_separator_tokens_1: |-
624+
client.index('books').resetSeparatorTokens()
625+
get_non_separator_tokens_1: |-
626+
client.index('books').getNonSeparatorTokens()
627+
update_non_separator_tokens_1: |-
628+
client.index('books').updateNonSeparatorTokens(['@', '#'])
629+
reset_non_separator_tokens_1: |-
630+
client.index('books').resetNonSeparatorTokens()
613631
search_parameter_guide_facet_stats_1: |-
614632
client.index('movie_ratings').search('Batman', { facets: ['genres', 'rating'] })
615633
geosearch_guide_filter_settings_1: |-

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
dist
3+
*.md

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,67 @@ client.index('myIndex').updateTypoTolerance(typoTolerance: TypoTolerance | null)
900900
client.index('myIndex').resetTypoTolerance(): Promise<EnqueuedTask>
901901
```
902902

903+
904+
### Separator tokens <!-- omit in toc -->
905+
906+
#### Get separator tokens
907+
908+
```ts
909+
client.index('myIndex').getSeparatorTokens(): Promise<SeparatorTokens>
910+
```
911+
912+
#### Update separator tokens
913+
914+
```ts
915+
client.index('myIndex').updateSeparatorTokens(separatorTokens: SeparatorTokens | null): Promise<EnqueuedTask>
916+
```
917+
918+
#### Reset separator tokens
919+
920+
```ts
921+
client.index('myIndex').resetSeparatorTokens(): Promise<EnqueuedTask>
922+
```
923+
924+
### Non Separator tokens <!-- omit in toc -->
925+
926+
#### Get non separator tokens
927+
928+
```ts
929+
client.index('myIndex').getNonSeparatorTokens(): Promise<NonSeparatorTokens>
930+
```
931+
932+
#### Update non separator tokens
933+
934+
```ts
935+
client.index('myIndex').updateNonSeparatorTokens(nonSeparatorTokens: NonSeparatorTokens | null): Promise<EnqueuedTask>
936+
```
937+
938+
#### Reset non separator tokens
939+
940+
```ts
941+
client.index('myIndex').resetNonSeparatorTokens(): Promise<EnqueuedTask>
942+
```
943+
944+
### Dictionary <!-- omit in toc -->
945+
946+
#### Get dictionary
947+
948+
```ts
949+
client.index('myIndex').getDictionary(): Promise<Dictionary>
950+
```
951+
952+
#### Update dictionary
953+
954+
```ts
955+
client.index('myIndex').updateDictionary(dictionary: Dictionary | null): Promise<EnqueuedTask>
956+
```
957+
958+
#### Reset dictionary
959+
960+
```ts
961+
client.index('myIndex').resetDictionary(): Promise<EnqueuedTask>
962+
```
963+
903964
### Keys <!-- omit in toc -->
904965

905966
#### [Get keys](https://www.meilisearch.com/docs/reference/api/keys#get-all-keys)

src/indexes.ts

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import {
4747
DocumentsDeletionQuery,
4848
SearchForFacetValuesParams,
4949
SearchForFacetValuesResponse,
50+
SeparatorTokens,
51+
NonSeparatorTokens,
52+
Dictionary,
5053
} from './types'
5154
import { removeUndefinedFromObject } from './utils'
5255
import { HttpRequests } from './http-requests'
@@ -1117,6 +1120,133 @@ class Index<T extends Record<string, any> = Record<string, any>> {
11171120

11181121
return new EnqueuedTask(task)
11191122
}
1123+
1124+
///
1125+
/// SEPARATOR TOKENS
1126+
///
1127+
1128+
/**
1129+
* Get the list of all separator tokens.
1130+
*
1131+
* @returns Promise containing array of separator tokens
1132+
*/
1133+
async getSeparatorTokens(): Promise<string[]> {
1134+
const url = `indexes/${this.uid}/settings/separator-tokens`
1135+
return await this.httpRequest.get<string[]>(url)
1136+
}
1137+
1138+
/**
1139+
* Update the list of separator tokens. Overwrite the old list.
1140+
*
1141+
* @param separatorTokens - Array that contains separator tokens.
1142+
* @returns Promise containing an EnqueuedTask or null
1143+
*/
1144+
async updateSeparatorTokens(
1145+
separatorTokens: SeparatorTokens
1146+
): Promise<EnqueuedTask> {
1147+
const url = `indexes/${this.uid}/settings/separator-tokens`
1148+
const task = await this.httpRequest.put(url, separatorTokens)
1149+
1150+
return new EnqueuedTask(task)
1151+
}
1152+
1153+
/**
1154+
* Reset the separator tokens list to its default value
1155+
*
1156+
* @returns Promise containing an EnqueuedTask
1157+
*/
1158+
async resetSeparatorTokens(): Promise<EnqueuedTask> {
1159+
const url = `indexes/${this.uid}/settings/separator-tokens`
1160+
const task = await this.httpRequest.delete<EnqueuedTask>(url)
1161+
1162+
task.enqueuedAt = new Date(task.enqueuedAt)
1163+
1164+
return task
1165+
}
1166+
1167+
///
1168+
/// NON-SEPARATOR TOKENS
1169+
///
1170+
1171+
/**
1172+
* Get the list of all non-separator tokens.
1173+
*
1174+
* @returns Promise containing array of non-separator tokens
1175+
*/
1176+
async getNonSeparatorTokens(): Promise<string[]> {
1177+
const url = `indexes/${this.uid}/settings/non-separator-tokens`
1178+
return await this.httpRequest.get<string[]>(url)
1179+
}
1180+
1181+
/**
1182+
* Update the list of non-separator tokens. Overwrite the old list.
1183+
*
1184+
* @param nonSeparatorTokens - Array that contains non-separator tokens.
1185+
* @returns Promise containing an EnqueuedTask or null
1186+
*/
1187+
async updateNonSeparatorTokens(
1188+
nonSeparatorTokens: NonSeparatorTokens
1189+
): Promise<EnqueuedTask> {
1190+
const url = `indexes/${this.uid}/settings/non-separator-tokens`
1191+
const task = await this.httpRequest.put(url, nonSeparatorTokens)
1192+
1193+
return new EnqueuedTask(task)
1194+
}
1195+
1196+
/**
1197+
* Reset the non-separator tokens list to its default value
1198+
*
1199+
* @returns Promise containing an EnqueuedTask
1200+
*/
1201+
async resetNonSeparatorTokens(): Promise<EnqueuedTask> {
1202+
const url = `indexes/${this.uid}/settings/non-separator-tokens`
1203+
const task = await this.httpRequest.delete<EnqueuedTask>(url)
1204+
1205+
task.enqueuedAt = new Date(task.enqueuedAt)
1206+
1207+
return task
1208+
}
1209+
1210+
///
1211+
/// DICTIONARY
1212+
///
1213+
1214+
/**
1215+
* Get the dictionary settings of a Meilisearch index.
1216+
*
1217+
* @returns Promise containing the dictionary settings
1218+
*/
1219+
async getDictionary(): Promise<string[]> {
1220+
const url = `indexes/${this.uid}/settings/dictionary`
1221+
return await this.httpRequest.get<string[]>(url)
1222+
}
1223+
1224+
/**
1225+
* Update the the dictionary settings. Overwrite the old settings.
1226+
*
1227+
* @param dictionary - Array that contains the new dictionary settings.
1228+
* @returns Promise containing an EnqueuedTask or null
1229+
*/
1230+
async updateDictionary(dictionary: Dictionary): Promise<EnqueuedTask> {
1231+
const url = `indexes/${this.uid}/settings/dictionary`
1232+
const task = await this.httpRequest.put(url, dictionary)
1233+
1234+
return new EnqueuedTask(task)
1235+
}
1236+
1237+
/**
1238+
* Reset the dictionary settings to its default value
1239+
*
1240+
* @returns Promise containing an EnqueuedTask
1241+
*/
1242+
async resetDictionary(): Promise<EnqueuedTask> {
1243+
const url = `indexes/${this.uid}/settings/dictionary`
1244+
const task = await this.httpRequest.delete<EnqueuedTask>(url)
1245+
1246+
task.enqueuedAt = new Date(task.enqueuedAt)
1247+
1248+
return task
1249+
}
11201250
}
11211251

11221252
export { Index }

src/types/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ export type TypoTolerance = {
312312
twoTypos?: number | null
313313
}
314314
} | null
315+
export type SeparatorTokens = string[] | null
316+
export type NonSeparatorTokens = string[] | null
317+
export type Dictionary = string[] | null
315318

316319
export type FacetOrder = 'alpha' | 'count'
317320

@@ -336,6 +339,9 @@ export type Settings = {
336339
typoTolerance?: TypoTolerance
337340
faceting?: Faceting
338341
pagination?: PaginationSettings
342+
separatorTokens?: SeparatorTokens
343+
nonSeparatorTokens?: NonSeparatorTokens
344+
dictionary?: Dictionary
339345
}
340346

341347
/*

0 commit comments

Comments
 (0)