AlgoliaSearch\Index::saveObject PHP Method

saveObject() public method

Override the content of object.
public saveObject ( array $object, string $objectIDKey = 'objectID' ) : mixed
$object array contains the object to save, the object must contains an objectID attribute or attribute specified in $objectIDKey considered as objectID
$objectIDKey string
return mixed
    public function saveObject($object, $objectIDKey = 'objectID')
    {
        return $this->client->request($this->context, 'PUT', '/1/indexes/' . $this->urlIndexName . '/' . urlencode($object[$objectIDKey]), array(), $object, $this->context->writeHostsArray, $this->context->connectTimeout, $this->context->readTimeout);
    }

Usage Example

Example #1
0
 /**
  * Add or update the given searchable subject to the index.
  *
  * @param Searchable $subject
  */
 public function upsertToIndex(Searchable $subject)
 {
     $this->index->saveObject(array_merge($subject->getSearchableBody(), ['objectID' => $this->getAlgoliaId($subject)]));
 }
All Usage Examples Of AlgoliaSearch\Index::saveObject