/** * Bulk Delete a collection of Models. * * @param array|collection $collection * * @return mixed */ public function bulkDelete($collection = []) { $params = []; $defaultIndex = $this->connection->getDefaultIndex(); foreach ($collection as $item) { $modelIndex = $item->getDocumentIndex(); $params['body'][] = ['delete' => ['_id' => $item->getKey(), '_type' => $item->getDocumentType(), '_index' => $modelIndex ? $modelIndex : $defaultIndex]]; } return $this->connection->bulkStatement($params); }
/** * Execute the blueprint against the database. * * @param Connection $connection * @param Grammar $grammar * * @return array */ public function build(Connection $connection, Grammar $grammar) { $statement = ['index' => $this->index, 'type' => $this->type, 'body' => [$this->type => ['_source' => ['enabled' => true], 'properties' => $this->toDSL($grammar)]]]; return $connection->mapStatement($statement); }
/** * Execute the search query against elastic and return the raw result. * * @return array */ public function getRaw() { $params = ['index' => $this->getIndex(), 'type' => $this->getType(), 'body' => $this->toDSL()]; return $this->connection->searchStatement($params); }
/** * Execute the suggest query against elastic and return the raw result if model not set. * * @return array */ public function get() { return $this->connection->suggestStatement(['index' => $this->getIndex(), 'body' => $this->toDSL()]); }
/** * Schema constructor. * * @param Connection $connection */ public function __construct(Connection $connection) { $this->connection = $connection; $this->grammar = $connection->getMapGrammar(); }