backend/helper/scout-sonic-engine/src/SonicEngine.php
/**
     * Update the given model in the index.
     *
     * @param  \Illuminate\Database\Eloquent\Collection  $models
     * @throws \SonicSearch\NoConnectionException If the connection to Sonic has been lost in the meantime.
     * @throws \SonicSearch\CommandFailedException If execution of the command failed for which-ever reason.
     * @throws \SonicSearch\InvalidArgumentException If the given set of terms could not fit into Sonics receive buffer.
     *
     * @return void
     */
Update the given model in the index.

@return void
Update the given model in the index . @return void
public function update($models)
    {
        if ($models->isEmpty()) {
            return;
        }
        $this->ingest->ping();
        $messages = $models->map(function ($model) {
            if (empty($searchableData = $model->toSearchableArray())) {
                return;
            }
            $bucket = class_basename($model);
            return [
                str_plural($bucket),
                $bucket,
                $model->getScoutKey(),
                is_array($searchableData) ? implode(' ', array_values($searchableData)) : $searchableData,
            ];
        })->filter()->all();
        if (!empty($messages)) {
            foreach ($messages as $message) {
                $this->ingest->push(...$message);
            }
            $this->control->consolidate();
        }
    }
public function update ( $ models ) { if ( $ models -> isEmpty ( ) ) { return ; } $ this -> ingest -> ping ( ) ; $ messages = $ models -> map ( function ( $ model ) { if ( empty ( $ searchableData = $ model -> toSearchableArray ( ) ) ) { return ; } $ bucket = class_basename ( $ model ) ; return [ str_plural ( $ bucket ) , $ bucket , $ model -> getScoutKey ( ) , is_array ( $ searchableData ) ? implode ( ' ' , array_values ( $ searchableData ) ) : $ searchableData , ] ; } ) -> filter ( ) -> all ( ) ; if ( ! empty ( $ messages ) ) { foreach ( $ messages as $ message ) { $ this -> ingest -> push ( ... $ message ) ; } $ this -> control -> consolidate ( ) ; } }
Update the given model in the index.
Update the given model in the index .
// save to disk