|
259 | 259 | } |
260 | 260 | ) |
261 | 261 | end |
| 262 | + |
| 263 | + it '#update_documents_ndjson_in_batches' do |
| 264 | + index.add_documents_ndjson(ndjson_docs, 'objectRef').await |
| 265 | + |
| 266 | + edits = <<~EDITS |
| 267 | + { "objectRef": 123, "comment": "AN OLD BOOK" } |
| 268 | + { "objectRef": 456, "title": "The Little Prince" } |
| 269 | + { "objectRef": 55, "comment": "A SCI FI BOOK" } |
| 270 | + EDITS |
| 271 | + |
| 272 | + tasks = index.update_documents_ndjson_in_batches(edits, 2) |
| 273 | + expect(tasks).to contain_exactly(a_kind_of(Meilisearch::Models::Task), |
| 274 | + a_kind_of(Meilisearch::Models::Task)) |
| 275 | + tasks.each(&:await) |
| 276 | + expect(index.documents['results']).to include( |
| 277 | + { |
| 278 | + 'objectRef' => 123, |
| 279 | + 'title' => 'Pride and Prejudice', |
| 280 | + 'comment' => 'AN OLD BOOK' |
| 281 | + }, |
| 282 | + { |
| 283 | + 'objectRef' => 456, |
| 284 | + 'title' => 'The Little Prince', |
| 285 | + 'comment' => 'A french book' |
| 286 | + }, |
| 287 | + { |
| 288 | + 'objectRef' => 55, |
| 289 | + 'title' => 'The Three Body Problem', |
| 290 | + 'comment' => 'A SCI FI BOOK' |
| 291 | + } |
| 292 | + ) |
| 293 | + end |
| 294 | + |
| 295 | + it '#update_documents_csv_in_batches' do |
| 296 | + index.add_documents_csv(csv_docs, 'objectRef').await |
| 297 | + edits = <<~CSV |
| 298 | + "objectRef:number"|"comment:string" |
| 299 | + "123"|"AN OLD BOOK" |
| 300 | + "456"|"AN EXQUISITE FRENCH BOOK" |
| 301 | + "55"|"A SCI FI BOOK" |
| 302 | + CSV |
| 303 | + |
| 304 | + tasks = index.update_documents_csv_in_batches(edits, 2, 'objectRef', '|') |
| 305 | + expect(tasks).to contain_exactly(a_kind_of(Meilisearch::Models::Task), |
| 306 | + a_kind_of(Meilisearch::Models::Task)) |
| 307 | + tasks.each(&:await) |
| 308 | + |
| 309 | + expect(index.documents['results']).to include( |
| 310 | + { |
| 311 | + 'objectRef' => 123, |
| 312 | + 'title' => 'Pride and Prejudice', |
| 313 | + 'comment' => 'AN OLD BOOK' |
| 314 | + }, |
| 315 | + { |
| 316 | + 'objectRef' => 456, |
| 317 | + 'title' => 'Le Petit Prince', |
| 318 | + 'comment' => 'AN EXQUISITE FRENCH BOOK' |
| 319 | + }, |
| 320 | + { |
| 321 | + 'objectRef' => 55, |
| 322 | + 'title' => 'The Three Body Problem', |
| 323 | + 'comment' => 'A SCI FI BOOK' |
| 324 | + } |
| 325 | + ) |
| 326 | + end |
262 | 327 | end |
263 | 328 |
|
264 | 329 | describe '#add_documents!' do |
|
0 commit comments