Skip to content

Commit 88014be

Browse files
author
charlotte
committed
Index naming and memberOf fixing
1 parent 8fadbc8 commit 88014be

File tree

5 files changed

+154
-150
lines changed

5 files changed

+154
-150
lines changed

README.md

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ const config = {
6060
const meili = new MeiliSearch(config)
6161

6262
await meili.createIndex({ uid: 'books' }) // if your index does not exist
63-
let index = await meili.getIndex('books') // If you already created your index
63+
const index = await meili.getIndex('books');
6464

65-
let documents = [
65+
const documents = [
6666
{ book_id: 123, title: 'Pride and Prejudice' },
6767
{ book_id: 456, title: 'Le Petit Prince' },
6868
{ book_id: 1, title: 'Alice In Wonderland' },
@@ -80,7 +80,7 @@ With the `updateId`, you can check the status (`processed` of `failed`) of your
8080

8181
```javascript
8282
// MeiliSearch is typo-tolerant:
83-
await meili.getIndex('books').search('harry pottre')
83+
await index.search('harry pottre')
8484
```
8585

8686
Output:
@@ -124,10 +124,10 @@ meili.createIndex({ uid: 'books', primaryKey: 'book_id' }) // if your index does
124124
await meili.listIndexes()
125125
```
126126

127-
#### Get an index <!-- omit in toc -->
127+
#### Get an index object <!-- omit in toc -->
128128

129129
```javascript
130-
await meili.getIndex('books').getIndex()
130+
const index = await meili.getIndex('books')
131131
```
132132

133133
### Documents
@@ -136,20 +136,16 @@ await meili.getIndex('books').getIndex()
136136

137137
```javascript
138138
// Get one document
139-
let myDocument = await meili.getIndex('books').getDocument(123)
139+
let myDocument = await index.getDocument(123)
140140

141141
// Get documents by batch
142-
let myDocuments = await meili
143-
.getIndex('books')
144-
.getDocuments({ offset: 4, limit: 20 })
142+
let myDocuments = await index.getDocuments({ offset: 4, limit: 20 })
145143
```
146144

147145
#### Add documents <!-- omit in toc -->
148146

149147
```javascript
150-
meili
151-
.getIndex('books')
152-
.addOrReplaceDocuments([{ book_id: 2, title: 'Madame Bovary' }])
148+
index.addOrReplaceDocuments([{ book_id: 2, title: 'Madame Bovary' }])
153149
```
154150

155151
Response:
@@ -166,29 +162,29 @@ With this `updateId` you can track your [operation update](#update-status).
166162

167163
```javascript
168164
// Delete one document
169-
await meili.getIndex('books').deleteDocument(2)
165+
index.deleteDocument(2)
170166
// Delete several documents
171-
await meili.getIndex('books').deleteDocuments([1, 42])
167+
index.deleteDocuments([1, 42])
172168
// Delete all documents /!\
173-
await meili.getIndex('books').deleteAllDocuments()
169+
index.deleteAllDocuments()
174170
```
175171

176172
### Update status
177173

178174
```javascript
179175
// Get one update
180176
// Parameter: the updateId got after an asynchronous request (e.g. documents addition)
181-
await meili.getIndex('books').getUpdateStatus(1)
177+
await index.getUpdateStatus(1)
182178
// Get all update satus
183-
await meili.getIndex('books').getAllUpdateStatus()
179+
await index.getAllUpdateStatus()
184180
```
185181

186182
### Search
187183

188184
#### Basic search <!-- omit in toc -->
189185

190186
```javascript
191-
await meili.getIndex('books').search('prince')
187+
await index.search('prince')
192188
```
193189

194190
```json
@@ -215,9 +211,7 @@ await meili.getIndex('books').search('prince')
215211
All the supported options are described in [this documentation section](https://docs.meilisearch.com/references/search.html#search-in-an-index).
216212

217213
```javascript
218-
await meili
219-
.getIndex('books')
220-
.search('prince', { limit: 1, attributesToHighlight: '*' })
214+
await index.search('prince', { limit: 1, attributesToHighlight: '*' })
221215
```
222216

223217
```json
@@ -308,77 +302,81 @@ This package works for MeiliSearch `v0.9.x`.
308302

309303
`meili.createIndex(data: Types.CreateIndexRequest): Promise<Types.CreateIndexResponse>`
310304

311-
- Get Index:
305+
- Get index object:
312306

313-
`meili.getIndex('xxx').getIndex(): Promise<Types.index>`
307+
`meili.getIndex(uid: string)`
308+
309+
- Show Index information:
310+
311+
`index.show(): Promise<Types.index>`
314312

315313
- Update Index:
316314

317-
`meili.getIndex('xxx').updateIndex(data: Types.UpdateIndexRequest): Promise<Types.index>`
315+
`index.updateIndex(data: Types.UpdateIndexRequest): Promise<Types.index>`
318316

319317
- Delete Index:
320318

321-
`meili.getIndex('xxx').deleteIndex(): Promise<void>`
319+
`index.deleteIndex(): Promise<void>`
322320

323321
- Get specific index stats
324322

325-
`meili.getIndex('xxx').getStats(): Promise<object>`
323+
`index.getStats(): Promise<object>`
326324

327325
### Updates
328326

329327
- Get One update info:
330328

331-
`meili.getIndex('xxx').getUpdateStatus(updateId: number): Promise<object>`
329+
`index.getUpdateStatus(updateId: number): Promise<object>`
332330

333331
- Get all updates info:
334332

335-
`meili.getIndex('xxx').getAllUpdateStatus(): Promise<object[]>`
333+
`index.getAllUpdateStatus(): Promise<object[]>`
336334

337335
### Documents
338336

339337
- Add or replace multiple documents:
340338

341-
`meili.getIndex('xxx').addDocuments(documents: object[]): Promise<Types.AsyncUpdateId>`
339+
`index.addDocuments(documents: object[]): Promise<Types.AsyncUpdateId>`
342340

343341
- Add or update multiple documents:
344342

345-
`meili.getIndex('xxx').updateDocuments(documents: object[]): Promise<Types.AsyncUpdateId>`
343+
`index.updateDocuments(documents: object[]): Promise<Types.AsyncUpdateId>`
346344

347345
- Get Documents:
348346

349-
`meili.getIndex('xxx').getDocuments(params: Types.getDocumentsParams): Promise<object[]>`
347+
`index.getDocuments(params: Types.getDocumentsParams): Promise<object[]>`
350348

351349
- Get one document:
352350

353-
`meili.getIndex('xxx').getDocument(documentId: string): Promise<object>`
351+
`index.getDocument(documentId: string): Promise<object>`
354352

355353
- Delete one document:
356354

357-
`meili.getIndex('xxx').deleteDocument(documentId: string): Promise<Types.AsyncUpdateId>`
355+
`index.deleteDocument(documentId: string): Promise<Types.AsyncUpdateId>`
358356

359357
- Delete multiple documents:
360358

361-
`meili.getIndex('xxx').deleteDocuments(documentsIds: string[]): Promise<Types.AsyncUpdateId>`
359+
`index.deleteDocuments(documentsIds: string[]): Promise<Types.AsyncUpdateId>`
362360

363361
### Settings
364362

365363
- Get settings:
366364

367-
`meili.getIndex('xxx').getSettings(): Promise<object>`
365+
`index.getSettings(): Promise<object>`
368366

369367
- Update settings:
370368

371-
`meili.getIndex('xxx').updateSettings(settings: object): Promise<void>`
369+
`index.updateSettings(settings: object): Promise<void>`
372370

373371
### Synonyms
374372

375373
- List all synonyms:
376374

377-
`meili.getIndex('xxx').listSynonyms(): Promise<object[]>`
375+
`index.listSynonyms(): Promise<object[]>`
378376

379377
- Add a synonyms:
380378

381-
`meili.getIndex('xxx').createSynonym(input: string, synonyms: string[]): Promise<object>`
379+
`index.createSynonym(input: string, synonyms: string[]): Promise<object>`
382380

383381
#### Stop-words
384382

0 commit comments

Comments
 (0)