Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * 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()]);
 }
Ejemplo n.º 5
0
 /**
  * Schema constructor.
  *
  * @param Connection $connection
  */
 public function __construct(Connection $connection)
 {
     $this->connection = $connection;
     $this->grammar = $connection->getMapGrammar();
 }