@@ -60,8 +60,9 @@ const config = {
6060const meili = new MeiliSearch (config)
6161
6262await meili .createIndex ({ uid: ' books' }) // if your index does not exist
63+ const index = await meili .getIndex (' books' );
6364
64- let documents = [
65+ const documents = [
6566 { book_id: 123 , title: ' Pride and Prejudice' },
6667 { book_id: 456 , title: ' Le Petit Prince' },
6768 { book_id: 1 , title: ' Alice In Wonderland' },
@@ -70,7 +71,7 @@ let documents = [
7071 { book_id: 42 , title: " The Hitchhiker's Guide to the Galaxy" },
7172]
7273
73- await meili . Index ( ' books ' ) .addOrReplaceDocuments (documents) // { "updateId": 0 }
74+ await index .addOrReplaceDocuments (documents) // { "updateId": 0 }
7475```
7576
7677With the ` updateId ` , you can check the status (` processed ` of ` failed ` ) of your documents addition thanks to this [ method] ( #update-status ) .
@@ -79,7 +80,7 @@ With the `updateId`, you can check the status (`processed` of `failed`) of your
7980
8081``` javascript
8182// MeiliSearch is typo-tolerant:
82- await meili . Index ( ' books ' ) .search (' harry pottre' )
83+ await index .search (' harry pottre' )
8384```
8485
8586Output:
@@ -123,10 +124,10 @@ meili.createIndex({ uid: 'books', primaryKey: 'book_id' }) // if your index does
123124await meili .listIndexes ()
124125```
125126
126- #### Get an index <!-- omit in toc -->
127+ #### Get an index object <!-- omit in toc -->
127128
128129``` javascript
129- await meili .Index (' books' ). getIndex ( )
130+ const index = await meili .getIndex (' books' )
130131```
131132
132133### Documents
@@ -135,20 +136,16 @@ await meili.Index('books').getIndex()
135136
136137``` javascript
137138// Get one document
138- let myDocument = await meili . Index ( ' books ' ) .getDocument (123 )
139+ let myDocument = await index .getDocument (123 )
139140
140141// Get documents by batch
141- let myDocuments = await meili
142- .Index (' books' )
143- .getDocuments ({ offset: 4 , limit: 20 })
142+ let myDocuments = await index .getDocuments ({ offset: 4 , limit: 20 })
144143```
145144
146145#### Add documents <!-- omit in toc -->
147146
148147``` javascript
149- meili
150- .Index (' books' )
151- .addOrReplaceDocuments ([{ book_id: 2 , title: ' Madame Bovary' }])
148+ index .addOrReplaceDocuments ([{ book_id: 2 , title: ' Madame Bovary' }])
152149```
153150
154151Response:
@@ -165,29 +162,29 @@ With this `updateId` you can track your [operation update](#update-status).
165162
166163``` javascript
167164// Delete one document
168- await meili . Index ( ' books ' ) .deleteDocument (2 )
165+ index .deleteDocument (2 )
169166// Delete several documents
170- await meili . Index ( ' books ' ) .deleteDocuments ([1 , 42 ])
167+ index .deleteDocuments ([1 , 42 ])
171168// Delete all documents /!\
172- await meili . Index ( ' books ' ) .deleteAllDocuments ()
169+ index .deleteAllDocuments ()
173170```
174171
175172### Update status
176173
177174``` javascript
178175// Get one update
179176// Parameter: the updateId got after an asynchronous request (e.g. documents addition)
180- await meili . Index ( ' books ' ) .getUpdateStatus (1 )
177+ await index .getUpdateStatus (1 )
181178// Get all update satus
182- await meili . Index ( ' books ' ) .getAllUpdateStatus ()
179+ await index .getAllUpdateStatus ()
183180```
184181
185182### Search
186183
187184#### Basic search <!-- omit in toc -->
188185
189186``` javascript
190- await meili . Index ( ' books ' ) .search (' prince' )
187+ await index .search (' prince' )
191188```
192189
193190``` json
@@ -214,9 +211,7 @@ await meili.Index('books').search('prince')
214211All the supported options are described in [ this documentation section] ( https://docs.meilisearch.com/references/search.html#search-in-an-index ) .
215212
216213``` javascript
217- await meili
218- .Index (' books' )
219- .search (' prince' , { limit: 1 , attributesToHighlight: ' *' })
214+ await index .search (' prince' , { limit: 1 , attributesToHighlight: ' *' })
220215```
221216
222217``` json
@@ -295,7 +290,7 @@ This package works for MeiliSearch `v0.9.x`.
295290
296291- Make a search request:
297292
298- ` meili.Index ('xxx').search(query: string, options?: Types.SearchParams): Promise<Types.SearchResponse> `
293+ ` meili.getIndex ('xxx').search(query: string, options?: Types.SearchParams): Promise<Types.SearchResponse> `
299294
300295### Indexes
301296
@@ -307,77 +302,81 @@ This package works for MeiliSearch `v0.9.x`.
307302
308303` meili.createIndex(data: Types.CreateIndexRequest): Promise<Types.CreateIndexResponse> `
309304
310- - Get Index :
305+ - Get index object :
311306
312- ` meili.Index('xxx').getIndex(): Promise<Types.index> `
307+ ` meili.getIndex(uid: string) `
308+
309+ - Show Index information:
310+
311+ ` index.show(): Promise<Types.index> `
313312
314313- Update Index:
315314
316- ` meili.Index('xxx') .updateIndex(data: Types.UpdateIndexRequest): Promise<Types.index>`
315+ ` index .updateIndex(data: Types.UpdateIndexRequest): Promise<Types.index>`
317316
318317- Delete Index:
319318
320- ` meili.Index('xxx') .deleteIndex(): Promise<void>`
319+ ` index .deleteIndex(): Promise<void>`
321320
322321- Get specific index stats
323322
324- ` meili.Index('xxx') .getStats(): Promise<object>`
323+ ` index .getStats(): Promise<object>`
325324
326325### Updates
327326
328327- Get One update info:
329328
330- ` meili.Index('xxx') .getUpdateStatus(updateId: number): Promise<object>`
329+ ` index .getUpdateStatus(updateId: number): Promise<object>`
331330
332331- Get all updates info:
333332
334- ` meili.Index('xxx') .getAllUpdateStatus(): Promise<object[]>`
333+ ` index .getAllUpdateStatus(): Promise<object[]>`
335334
336335### Documents
337336
338337- Add or replace multiple documents:
339338
340- ` meili.Index('xxx') .addDocuments(documents: object[]): Promise<Types.AsyncUpdateId>`
339+ ` index .addDocuments(documents: object[]): Promise<Types.AsyncUpdateId>`
341340
342341- Add or update multiple documents:
343342
344- ` meili.Index('xxx') .updateDocuments(documents: object[]): Promise<Types.AsyncUpdateId>`
343+ ` index .updateDocuments(documents: object[]): Promise<Types.AsyncUpdateId>`
345344
346345- Get Documents:
347346
348- ` meili.Index('xxx') .getDocuments(params: Types.getDocumentsParams): Promise<object[]>`
347+ ` index .getDocuments(params: Types.getDocumentsParams): Promise<object[]>`
349348
350349- Get one document:
351350
352- ` meili.Index('xxx') .getDocument(documentId: string): Promise<object>`
351+ ` index .getDocument(documentId: string): Promise<object>`
353352
354353- Delete one document:
355354
356- ` meili.Index('xxx') .deleteDocument(documentId: string): Promise<Types.AsyncUpdateId>`
355+ ` index .deleteDocument(documentId: string): Promise<Types.AsyncUpdateId>`
357356
358357- Delete multiple documents:
359358
360- ` meili.Index('xxx') .deleteDocuments(documentsIds: string[]): Promise<Types.AsyncUpdateId>`
359+ ` index .deleteDocuments(documentsIds: string[]): Promise<Types.AsyncUpdateId>`
361360
362361### Settings
363362
364363- Get settings:
365364
366- ` meili.Index('xxx') .getSettings(): Promise<object>`
365+ ` index .getSettings(): Promise<object>`
367366
368367- Update settings:
369368
370- ` meili.Index('xxx') .updateSettings(settings: object): Promise<void>`
369+ ` index .updateSettings(settings: object): Promise<void>`
371370
372371### Synonyms
373372
374373- List all synonyms:
375374
376- ` meili.Index('xxx') .listSynonyms(): Promise<object[]>`
375+ ` index .listSynonyms(): Promise<object[]>`
377376
378377- Add a synonyms:
379378
380- ` meili.Index('xxx') .createSynonym(input: string, synonyms: string[]): Promise<object>`
379+ ` index .createSynonym(input: string, synonyms: string[]): Promise<object>`
381380
382381#### Stop-words
383382
0 commit comments