AlgoliaSearch\Index::saveObjects PHP Method

saveObjects() public method

Override the content of several objects.
public saveObjects ( array $objects, string $objectIDKey = 'objectID' ) : mixed
$objects array contains an array of objects to update (each object must contains a objectID attribute)
$objectIDKey string
return mixed
    public function saveObjects($objects, $objectIDKey = 'objectID')
    {
        $requests = $this->buildBatch('updateObject', $objects, true, $objectIDKey);
        return $this->batch($requests);
    }

Usage Example

Example #1
0
 public function it_adds_multiple_searchable_objects_to_the_search_index(\AlgoliaSearch\Index $index, Searchable $searchableObject)
 {
     $searchableObjects = [$searchableObject];
     $objects = [];
     $objects[] = array_merge($this->searchableBody, ['objectID' => $this->searchableType . '-' . $this->searchableId]);
     $index->saveObjects($objects)->shouldBeCalled();
     $this->upsertToIndex($searchableObjects);
 }
All Usage Examples Of AlgoliaSearch\Index::saveObjects