Skip to content

Commit 223b252

Browse files
committed
proto-beta: Tokenizer customization
1 parent d82d350 commit 223b252

File tree

11 files changed

+674
-2
lines changed

11 files changed

+674
-2
lines changed

.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
@@ -897,6 +897,67 @@ client.index('myIndex').updateTypoTolerance(typoTolerance: TypoTolerance | null)
897897
client.index('myIndex').resetTypoTolerance(): Promise<EnqueuedTask>
898898
```
899899

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

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "meilisearch",
3-
"version": "0.34.1",
3+
"version": "0.34.2-tokenizer-customization.0",
44
"description": "The Meilisearch JS client for Node.js and the browser.",
55
"keywords": [
66
"meilisearch",

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/package-version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const PACKAGE_VERSION = '0.34.1'
1+
export const PACKAGE_VERSION = '0.34.2-tokenizer-customization.0'

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)