meilisearch / meilisearch-php

PHP wrapper for the Meilisearch API

Home Page:https://meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update documents in batches is sending the same chunk all the time

brunoocasali opened this issue · comments

In this function updateDocumentsInBatches we use a method called self::batch to split a big array into smaller chunks to improve the performance.

But after doing that, we are sending the same $documents array where it should be $batch:

// current:
        foreach (self::batch($documents, $batchSize) as $batch) {
            $promises[] = $this-> updateDocuments($documents, $primaryKey);
        }
        
// should be:
        foreach (self::batch($documents, $batchSize) as $batch) {
            $promises[] = $this-> updateDocuments($batch, $primaryKey);
        }

This is the affected code:

public function updateDocumentsInBatches(array $documents, ?int $batchSize = 1000, ?string $primaryKey = null)

We should also fix this testAddDocumentsInBatches test case.