Skip to content

Commit d3593cd

Browse files
meili-bors[bot]meili-botStriftcurquizaBarabasbalazs
authored
Merge #1768
1768: Changes related to the next Meilisearch release (v1.12.0) r=curquiza a=meili-bot Related to this issue: meilisearch/integration-guides#307 This PR: - gathers the changes related to the next Meilisearch release (v1.12.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.12.0 is out. ⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.12.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: Strift <[email protected]> Co-authored-by: Clémentine <[email protected]> Co-authored-by: Laurent Cazanove <[email protected]> Co-authored-by: Balazs Barabas <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 parents 912465a + 966d534 commit d3593cd

20 files changed

+1267
-77
lines changed

.code-samples.meilisearch.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,19 @@ update_localized_attribute_settings_1: |-
808808
];)
809809
reset_localized_attribute_settings_1: |-
810810
client.index('INDEX_NAME').resetLocalizedAttributes()
811+
get_facet_search_settings_1: |-
812+
client.index('INDEX_NAME').getFacetSearch();
813+
update_facet_search_settings_1: |-
814+
client.index('INDEX_NAME').updateFacetSearch(false);
815+
reset_facet_search_settings_1: |-
816+
client.index('INDEX_NAME').resetFacetSearch();
817+
get_prefix_search_settings_1: |-
818+
client.index('INDEX_NAME').getPrefixSearch();
819+
update_prefix_search_settings_1: |-
820+
client.index('INDEX_NAME').updatePrefixSearch('disabled');
821+
reset_prefix_search_settings_1: |-
822+
client.index('INDEX_NAME').resetPrefixSearch();
823+
get_all_batches_1: |-
824+
client.getBatches();
825+
get_batch_1: |-
826+
client.getBatch(BATCH_UID);

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,20 @@ client.waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number })
565565
client.index('myIndex').waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise<Task[]>
566566
```
567567

568+
### Batches <!-- omit in toc -->
569+
570+
#### [Get one batch](https://www.meilisearch.com/docs/reference/api/batches#get-one-batch)
571+
572+
```ts
573+
client.getBatch(uid: number): Promise<Batch>
574+
```
575+
576+
#### [Get all batches](https://www.meilisearch.com/docs/reference/api/batchess#get-batches)
577+
578+
```ts
579+
client.getBatches(parameters: BatchesQuery = {}): Promise<BatchesResults>
580+
```
581+
568582
### Indexes <!-- omit in toc -->
569583

570584
#### [Get all indexes in Index instances](https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes)
@@ -981,6 +995,46 @@ client.index('myIndex').updateProximityPrecision(proximityPrecision: ProximityPr
981995
client.index('myIndex').resetProximityPrecision(): Promise<EnqueuedTask>
982996
```
983997

998+
### Facet search settings <!-- omit in toc -->
999+
1000+
#### [Get facet search settings](https://www.meilisearch.com/docs/reference/api/settings#get-facet-search-settings)
1001+
1002+
```ts
1003+
client.index('myIndex').getFacetSearch(): Promise<boolean>
1004+
```
1005+
1006+
#### [Update facet search settings](https://www.meilisearch.com/docs/reference/api/settings#update-facet-search-settings)
1007+
1008+
```ts
1009+
client.index('myIndex').updateFacetSearch(enabled: boolean): Promise<EnqueuedTask>
1010+
```
1011+
1012+
#### [Reset facet search settings](https://www.meilisearch.com/docs/reference/api/settings#reset-facet-search-settings)
1013+
1014+
```ts
1015+
client.index('myIndex').resetFacetSearch(): Promise<EnqueuedTask>
1016+
```
1017+
1018+
### Prefix search settings <!-- omit in toc -->
1019+
1020+
#### [Get prefix search settings](https://www.meilisearch.com/docs/reference/api/settings#get-prefix-search-settings)
1021+
1022+
```ts
1023+
client.index('myIndex').getPrefixSearch(): Promise<PrefixSearch>
1024+
```
1025+
1026+
#### [Update prefix search settings](https://www.meilisearch.com/docs/reference/api/settings#update-prefix-search-settings)
1027+
1028+
```ts
1029+
client.index('myIndex').updatePrefixSearch(prefixSearch: PrefixSearch): Promise<EnqueuedTask>
1030+
```
1031+
1032+
#### [Reset prefix search settings](https://www.meilisearch.com/docs/reference/api/settings#reset-prefix-search-settings)
1033+
1034+
```ts
1035+
client.index('myIndex').resetPrefixSearch(): Promise<EnqueuedTask>
1036+
```
1037+
9841038
### Embedders <!-- omit in toc -->
9851039

9861040
⚠️ This feature is experimental. Activate the [`vectorStore` experimental feature to use it](https://www.meilisearch.com/docs/reference/api/experimental_features#configure-experimental-features)

src/batch.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import {
2+
Config,
3+
BatchObject,
4+
BatchesQuery,
5+
BatchesResults,
6+
BatchesResultsObject,
7+
} from "./types";
8+
import { HttpRequests, toQueryParams } from "./http-requests";
9+
10+
class Batch {
11+
uid: BatchObject["uid"];
12+
details: BatchObject["details"];
13+
stats: BatchObject["stats"];
14+
startedAt: BatchObject["startedAt"];
15+
finishedAt: BatchObject["finishedAt"];
16+
duration: BatchObject["duration"];
17+
progress: BatchObject["progress"];
18+
19+
constructor(batch: BatchObject) {
20+
this.uid = batch.uid;
21+
this.details = batch.details;
22+
this.stats = batch.stats;
23+
this.startedAt = batch.startedAt;
24+
this.finishedAt = batch.finishedAt;
25+
this.duration = batch.duration;
26+
this.progress = batch.progress;
27+
}
28+
}
29+
30+
class BatchClient {
31+
httpRequest: HttpRequests;
32+
33+
constructor(config: Config) {
34+
this.httpRequest = new HttpRequests(config);
35+
}
36+
37+
/**
38+
* Get one batch
39+
*
40+
* @param uid - Unique identifier of the batch
41+
* @returns
42+
*/
43+
async getBatch(uid: number): Promise<Batch> {
44+
const url = `batches/${uid}`;
45+
const batch = await this.httpRequest.get<BatchObject>(url);
46+
return new Batch(batch);
47+
}
48+
49+
/**
50+
* Get batches
51+
*
52+
* @param parameters - Parameters to browse the batches
53+
* @returns Promise containing all batches
54+
*/
55+
async getBatches(parameters: BatchesQuery = {}): Promise<BatchesResults> {
56+
const url = `batches`;
57+
58+
const batches = await this.httpRequest.get<Promise<BatchesResultsObject>>(
59+
url,
60+
toQueryParams<BatchesQuery>(parameters),
61+
);
62+
63+
return {
64+
...batches,
65+
results: batches.results.map((batch) => new Batch(batch)),
66+
};
67+
}
68+
}
69+
70+
export { BatchClient, Batch };

src/indexes.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
SearchSimilarDocumentsParams,
5757
LocalizedAttributes,
5858
UpdateDocumentsByFunctionOptions,
59+
PrefixSearch,
5960
} from "./types";
6061
import { removeUndefinedFromObject } from "./utils";
6162
import { HttpRequests } from "./http-requests";
@@ -1457,6 +1458,80 @@ class Index<T extends Record<string, any> = Record<string, any>> {
14571458

14581459
return new EnqueuedTask(task);
14591460
}
1461+
1462+
///
1463+
/// FACET SEARCH SETTINGS
1464+
///
1465+
1466+
/**
1467+
* Get the facet search settings.
1468+
*
1469+
* @returns Promise containing object of facet search settings
1470+
*/
1471+
async getFacetSearch(): Promise<boolean> {
1472+
const url = `indexes/${this.uid}/settings/facet-search`;
1473+
return await this.httpRequest.get<boolean>(url);
1474+
}
1475+
1476+
/**
1477+
* Update the facet search settings.
1478+
*
1479+
* @param facetSearch - Boolean value
1480+
* @returns Promise containing an EnqueuedTask
1481+
*/
1482+
async updateFacetSearch(facetSearch: boolean): Promise<EnqueuedTask> {
1483+
const url = `indexes/${this.uid}/settings/facet-search`;
1484+
const task = await this.httpRequest.put(url, facetSearch);
1485+
return new EnqueuedTask(task);
1486+
}
1487+
1488+
/**
1489+
* Reset the facet search settings.
1490+
*
1491+
* @returns Promise containing an EnqueuedTask
1492+
*/
1493+
async resetFacetSearch(): Promise<EnqueuedTask> {
1494+
const url = `indexes/${this.uid}/settings/facet-search`;
1495+
const task = await this.httpRequest.delete(url);
1496+
return new EnqueuedTask(task);
1497+
}
1498+
1499+
///
1500+
/// PREFIX SEARCH SETTINGS
1501+
///
1502+
1503+
/**
1504+
* Get the prefix search settings.
1505+
*
1506+
* @returns Promise containing object of prefix search settings
1507+
*/
1508+
async getPrefixSearch(): Promise<PrefixSearch> {
1509+
const url = `indexes/${this.uid}/settings/prefix-search`;
1510+
return await this.httpRequest.get<PrefixSearch>(url);
1511+
}
1512+
1513+
/**
1514+
* Update the prefix search settings.
1515+
*
1516+
* @param prefixSearch - PrefixSearch value
1517+
* @returns Promise containing an EnqueuedTask
1518+
*/
1519+
async updatePrefixSearch(prefixSearch: PrefixSearch): Promise<EnqueuedTask> {
1520+
const url = `indexes/${this.uid}/settings/prefix-search`;
1521+
const task = await this.httpRequest.put(url, prefixSearch);
1522+
return new EnqueuedTask(task);
1523+
}
1524+
1525+
/**
1526+
* Reset the prefix search settings.
1527+
*
1528+
* @returns Promise containing an EnqueuedTask
1529+
*/
1530+
async resetPrefixSearch(): Promise<EnqueuedTask> {
1531+
const url = `indexes/${this.uid}/settings/prefix-search`;
1532+
const task = await this.httpRequest.delete(url);
1533+
return new EnqueuedTask(task);
1534+
}
14601535
}
14611536

14621537
export { Index };

src/meilisearch.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ import {
3030
DeleteTasksQuery,
3131
MultiSearchParams,
3232
FederatedMultiSearchParams,
33+
BatchesResults,
34+
BatchesQuery,
3335
MultiSearchResponseOrSearchResponse,
3436
} from "./types";
3537
import { HttpRequests } from "./http-requests";
3638
import { TaskClient, Task } from "./task";
3739
import { EnqueuedTask } from "./enqueued-task";
40+
import { Batch, BatchClient } from "./batch";
3841

3942
export class MeiliSearch {
4043
config: Config;
4144
httpRequest: HttpRequests;
4245
tasks: TaskClient;
46+
batches: BatchClient;
4347

4448
/**
4549
* Creates new MeiliSearch instance
@@ -50,6 +54,7 @@ export class MeiliSearch {
5054
this.config = config;
5155
this.httpRequest = new HttpRequests(config);
5256
this.tasks = new TaskClient(config);
57+
this.batches = new BatchClient(config);
5358
}
5459

5560
/**
@@ -303,6 +308,26 @@ export class MeiliSearch {
303308
return await this.tasks.deleteTasks(parameters);
304309
}
305310

311+
/**
312+
* Get all the batches
313+
*
314+
* @param parameters - Parameters to browse the batches
315+
* @returns Promise returning all batches
316+
*/
317+
async getBatches(parameters: BatchesQuery = {}): Promise<BatchesResults> {
318+
return await this.batches.getBatches(parameters);
319+
}
320+
321+
/**
322+
* Get one batch
323+
*
324+
* @param uid - Batch identifier
325+
* @returns Promise returning a batch
326+
*/
327+
async getBatch(uid: number): Promise<Batch> {
328+
return await this.batches.getBatch(uid);
329+
}
330+
306331
///
307332
/// KEYS
308333
///

src/task.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Task {
1919
status: TaskObject["status"];
2020
type: TaskObject["type"];
2121
uid: TaskObject["uid"];
22+
batchUid: TaskObject["batchUid"];
2223
canceledBy: TaskObject["canceledBy"];
2324
details: TaskObject["details"];
2425
error: TaskObject["error"];
@@ -32,6 +33,7 @@ class Task {
3233
this.status = task.status;
3334
this.type = task.type;
3435
this.uid = task.uid;
36+
this.batchUid = task.batchUid;
3537
this.details = task.details;
3638
this.canceledBy = task.canceledBy;
3739
this.error = task.error;

0 commit comments

Comments
 (0)