AlgoliaSearch\Index::addObject PHP Method

addObject() public method

Add an object in this index.
public addObject ( array $content, string | null $objectID = null ) : mixed
$content array contains the object to add inside the index. The object is represented by an associative array
$objectID string | null (optional) an objectID you want to attribute to this object (if the attribute already exist the old object will be overwrite)
return mixed
    public function addObject($content, $objectID = null)
    {
        if ($objectID === null) {
            return $this->client->request($this->context, 'POST', '/1/indexes/' . $this->urlIndexName, array(), $content, $this->context->writeHostsArray, $this->context->connectTimeout, $this->context->readTimeout);
        }
        return $this->client->request($this->context, 'PUT', '/1/indexes/' . $this->urlIndexName . '/' . urlencode($objectID), array(), $content, $this->context->writeHostsArray, $this->context->connectTimeout, $this->context->readTimeout);
    }