You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
awaitclient.createIndex({ uid:'books' }) // only if your index does not exist
61
+
constindex=client.getIndex('books')
62
+
63
+
constdocuments=[
64
+
{ book_id:123, title:'Pride and Prejudice' },
65
+
{ book_id:456, title:'Le Petit Prince' },
66
+
{ book_id:1, title:'Alice In Wonderland' },
67
+
{ book_id:1344, title:'The Hobbit' },
68
+
{ book_id:4, title:'Harry Potter and the Half-Blood Prince' },
69
+
{ book_id:42, title:"The Hitchhiker's Guide to the Galaxy" },
70
+
]
71
+
72
+
let response =awaitindex.addDocuments(documents)
73
+
console.log(response) // => { "updateId": 0 }
74
+
})()
75
75
```
76
76
77
77
With the `updateId`, you can check the status (`processed` or `failed`) of your documents addition thanks to this [method](#update-status).
@@ -80,7 +80,8 @@ With the `updateId`, you can check the status (`processed` or `failed`) of your
80
80
81
81
```javascript
82
82
// MeiliSearch is typo-tolerant:
83
-
awaitindex.search('harry pottre')
83
+
constsearch=awaitindex.search('harry pottre')
84
+
console.log(search)
84
85
```
85
86
86
87
Output:
@@ -107,27 +108,30 @@ You can check out [the API documentation](https://docs.meilisearch.com/reference
107
108
108
109
Go checkout [examples](./examples)!
109
110
111
+
In this section, the examples contain the [`await` keyword](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await). This operator is used to wait for a `Promise`.<br>
112
+
Despite it is not detailled in the examples above, it can only be used inside an `async` function.
113
+
110
114
### Indexes
111
115
112
116
#### Create an index <!-- omit in toc -->
113
117
114
118
```javascript
115
119
// Create an index
116
-
meili.createIndex({ uid:'books' })// if your index does not exist
0 commit comments