Skip to content

Commit dae2846

Browse files
authored
Add consistent genres field and remove movies reference (#819)
1 parent d430beb commit dae2846

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ import { MeiliSearch } from 'meilisearch'
135135
const index = client.index('books') // If your index exists
136136

137137
const documents = [
138-
{ book_id: 123, title: 'Pride and Prejudice' },
139-
{ book_id: 456, title: 'Le Petit Prince' },
140-
{ book_id: 1, title: 'Alice In Wonderland' },
138+
{ book_id: 123, title: 'Pride and Prejudice', genres: ['drama', 'romance'] },
139+
{ book_id: 456, title: 'Le Petit Prince', genres: ['poetic'] },
140+
{ book_id: 1, title: 'Alice In Wonderland', genres: ['conceptual'] },
141141
{ book_id: 1344, title: 'The Hobbit' },
142-
{ book_id: 4, title: 'Harry Potter and the Half-Blood Prince', genre: 'fantasy' },
143-
{ book_id: 42, title: "The Hitchhiker's Guide to the Galaxy", genre: 'fantasy' }
142+
{ book_id: 4, title: 'Harry Potter and the Half-Blood Prince', genres: ['fantasy'] },
143+
{ book_id: 42, title: "The Hitchhiker's Guide to the Galaxy", genres: ['fantasy'] }
144144
]
145145

146-
// If the index 'movies' does not exist, MeiliSearch creates it when you first add the documents.
146+
// If the index 'books' does not exist, MeiliSearch creates it when you first add the documents.
147147
let response = await index.addDocuments(documents)
148148

149149
console.log(response) // => { "updateId": 0 }
@@ -222,8 +222,8 @@ Placeholder search makes it possible to receive hits based on your parameters wi
222222
await index.search(
223223
'',
224224
{
225-
facetFilters: ['genre:fantasy'],
226-
facetsDistribution: ['genre']
225+
facetFilters: ['genres:fantasy'],
226+
facetsDistribution: ['genres']
227227
}
228228
)
229229
```
@@ -234,12 +234,12 @@ await index.search(
234234
{
235235
"id": 4,
236236
"title": "Harry Potter and the Half-Blood Prince",
237-
"genre": "fantasy"
237+
"genres": "fantasy"
238238
},
239239
{
240240
"id": 42,
241241
"title": "The Hitchhiker's Guide to the Galaxy",
242-
"genre": "fantasy"
242+
"genres": "fantasy"
243243
}
244244
],
245245
"offset": 0,
@@ -248,7 +248,7 @@ await index.search(
248248
"exhaustiveNbHits": false,
249249
"processingTimeMs": 0,
250250
"query": "",
251-
"facetsDistribution": { "genre": { "fantasy": 2 } },
251+
"facetsDistribution": { "genres": { "fantasy": 2 } },
252252
"exhaustiveFacetsCount": true
253253
}
254254
```

0 commit comments

Comments
 (0)