Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@
],
"require": {
"php": ">=7.0",
"elasticsearch/elasticsearch": "~5.3.0",
"ongr/elasticsearch-dsl": "5.*",
"illuminate/container": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/contracts": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/console": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/pagination": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/support": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/database": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*"
"elasticsearch/elasticsearch": "^5.3.0",
"illuminate/container": "^5.2.0",
"illuminate/contracts": "^5.2.0",
"illuminate/console": "^5.2.0",
"illuminate/database": "^5.2.0",
"illuminate/filesystem": "^5.2.0",
"illuminate/http": "^5.2.0",
"illuminate/pagination": "^5.2.0",
"illuminate/support": "^5.2.0",
"ongr/elasticsearch-dsl": "^5.0.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpunit/phpunit": "^4.0.0",
"mockery/mockery": "^0.9.4",
"phpunit/php-code-coverage": "^2.1"
"phpunit/php-code-coverage": "^2.1.0"
},
"autoload": {
"psr-4": {
Expand Down
30 changes: 14 additions & 16 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ public function getMapBuilder()
/**
* Get map grammar instance for this connection.
*
* @return MapBuilder
* @return MapGrammar
*/
public function getMapGrammar()
{
return new MapGrammar();
}

/**
* Get DSL grammar instance for this connection.
* Get DSL query instance for this connection.
*
* @return DSLGrammar
* @return DSLQuery
*/
public function getDSLQuery()
{
return new DSLQuery();
}

/**
* Get the elastic search client instance.
* Get the Elasticsearch client instance.
*
* @return Client
*/
Expand All @@ -102,17 +102,15 @@ public function setClient(Client $client)
/**
* Set the default index.
*
* @param $index
*
* @return Connection
* @param string $index
*/
public function setDefaultIndex($index)
{
$this->index = $index;
}

/**
* Execute a map statement on index;.
* Execute a map statement on index.
*
* @param array $mappings
*
Expand All @@ -124,7 +122,7 @@ public function mapStatement(array $mappings)
}

/**
* Execute a map statement on index;.
* Execute a search statement on index.
*
* @param array $search
*
Expand All @@ -136,7 +134,7 @@ public function searchStatement(array $search)
}

/**
* Execute a map statement on index;.
* Execute a suggest statement on index.
*
* @param array $suggestions
*
Expand All @@ -148,7 +146,7 @@ public function suggestStatement(array $suggestions)
}

/**
* Execute a insert statement on index;.
* Execute an insert statement on index.
*
* @param $params
*
Expand All @@ -160,7 +158,7 @@ public function indexStatement(array $params)
}

/**
* Execute a update statement on index;.
* Execute an update statement on index.
*
* @param $params
*
Expand All @@ -172,7 +170,7 @@ public function updateStatement(array $params)
}

/**
* Execute a update statement on index;.
* Execute a delete statement on index.
*
* @param $params
*
Expand All @@ -184,7 +182,7 @@ public function deleteStatement(array $params)
}

/**
* Execute a exists statement on index.
* Execute an exists statement on index.
*
* @param array $params
*
Expand All @@ -196,7 +194,7 @@ public function existsStatement(array $params)
}

/**
* Execute a bulk statement on index;.
* Execute a bulk statement on index.
*
* @param $params
*
Expand Down Expand Up @@ -238,7 +236,7 @@ public function persist()
}

/**
* Create an elastic search instance.
* Create an Elasticsearch instance.
*
* @param array $config
*
Expand Down
4 changes: 3 additions & 1 deletion src/Console/Index/Populate.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function client()

/**
* Execute the console command.
*
* @throws \Exception
*/
public function handle()
{
Expand Down Expand Up @@ -94,7 +96,7 @@ protected function populateIndex($index)
foreach ($models as $model) {
$this->line('Indexing documents of model « '.$model.' » ...');
$model::chunk($chunkSize, function ($items) {
$this->line('Indexing chunk of '.$items->count().' documents ...');
$this->line('Indexing chunk of '.count($items).' documents ...');
Plastic::persist()->bulkSave($items);
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/Console/Mapping/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function __construct(Creator $creator, Composer $composer)

/**
* Execute the console command.
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function handle()
{
Expand All @@ -61,6 +63,8 @@ public function handle()
* Create the mapping file.
*
* @param $model
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
private function writeMapping($model)
{
Expand Down
11 changes: 6 additions & 5 deletions src/DSL/SearchBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SearchBuilder
public $index;

/**
* The model to use when querying elastic search.
* The model to use when querying Elasticsearch.
*
* @var Model
*/
Expand Down Expand Up @@ -99,7 +99,7 @@ class SearchBuilder
public function __construct(Connection $connection, Query $grammar = null)
{
$this->connection = $connection;
$this->query = $grammar ?: $connection->getDSLGrammar();
$this->query = $grammar ?: $connection->getDSLQuery();
}

/**
Expand Down Expand Up @@ -131,7 +131,7 @@ public function index($index)
}

/**
* Set the eloquent model to use when querying elastic search.
* Set the eloquent model to use when querying Elasticsearch.
*
* @param Model|Searchable $model
*
Expand Down Expand Up @@ -212,7 +212,7 @@ public function sortBy($fields, $order = null, array $parameters = [])
/**
* Set the query min score value.
*
* @param $score
* @param int $score
*
* @return $this
*/
Expand Down Expand Up @@ -500,7 +500,7 @@ public function geoShape($field, $type, array $coordinates = [], array $attribut
{
$query = new GeoShapeQuery();

$query->addShape($field, $type, $coordinates, $attributes);
$query->addShape($field, $type, $coordinates, GeoShapeQuery::INTERSECTS, $attributes);

$this->append($query);

Expand Down Expand Up @@ -610,6 +610,7 @@ public function range($field, array $attributes = [])
* Add a regexp query.
*
* @param string $field
* @param string $regex
* @param array $attributes
*
* @return $this
Expand Down
14 changes: 7 additions & 7 deletions src/DSL/SuggestionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function getIndex()
/**
* Add a completion suggestion.
*
* @param $name
* @param $text
* @param $field
* @param array $parameters
* @param string $name
* @param string $text
* @param string $field
* @param array $parameters
*
* @return $this
*
Expand All @@ -92,8 +92,8 @@ public function completion($name, $text, $field = 'suggest', $parameters = [])
*
* @param string $name
* @param string $text
* @param $field
* @param array $parameters
* @param string $field
* @param array $parameters
*
* @return $this
*/
Expand Down Expand Up @@ -144,7 +144,7 @@ public function getConnection()
/**
* Append a suggestion to query.
*
* @param $suggestion
* @param \ONGR\ElasticsearchDSL\BuilderInterface $suggestion
*/
public function append($suggestion)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Facades/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use Illuminate\Support\Facades\Facade;

/**
* @method static create(string $type, \Closure $callback, string $index = null) Create a map on your Elasticsearch index.
* @method static blueprintResolver(\Closure $resolver) Set the Schema Blueprint resolver callback.
*/
class Map extends Facade
{
/**
Expand All @@ -13,6 +17,7 @@ class Map extends Facade
*/
protected static function getFacadeAccessor()
{
/* @noinspection PhpUndefinedMethodInspection */
return static::$app['plastic']->connection()->getMapBuilder();
}
}
23 changes: 22 additions & 1 deletion src/Facades/Plastic.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,33 @@

use Illuminate\Support\Facades\Facade;

/**
* @method static \Sleimanx2\Plastic\Connection connection() Get an Elasticsearch connection instance.
* @method static string getDefaultIndex() Get the default elastic index.
* @method static \Sleimanx2\Plastic\Map\Builder getMapBuilder() Get map builder instance for this connection.
* @method static \Sleimanx2\Plastic\Map\Grammar getMapGrammar() Get map grammar instance for this connection.
* @method static \ONGR\ElasticsearchDSL\Search getDSLQuery() Get DSL grammar instance for this connection.
* @method static \Elasticsearch\Client getClient() Get the Elasticsearch client instance.
* @method static setClient(\Elasticsearch\Client $client) Set a custom elastic client.
* @method static setDefaultIndex(string $index) Set the default index.
* @method static array mapStatement(array $mappings) Execute a map statement on index.
* @method static array searchStatement(array $search) Execute a search statement on index.
* @method static array suggestStatement(array $suggestions) Execute a suggest statement on index.
* @method static array indexStatement(array $params) Execute an insert statement on index.
* @method static array updateStatement(array $params) Execute an update statement on index.
* @method static array deleteStatement(array $params) Execute a delete statement on index.
* @method static array|bool existsStatement(array $params) Execute an exists statement on index.
* @method static array bulkStatement(array $params) Execute a bulk statement on index.
* @method static \Sleimanx2\Plastic\DSL\SearchBuilder search() Begin a fluent search query builder.
* @method static \Sleimanx2\Plastic\DSL\SuggestionBuilder suggest() Begin a fluent suggest query builder.
* @method static \Sleimanx2\Plastic\Persistence\EloquentPersistence persist() Create a new elastic persistence handler.
*/
class Plastic extends Facade
{
/**
* Get a plastic manager instance for the default connection.
*
* @return \Sleimanx2\Plastic\DSL\SearchBuilder
* @return \Sleimanx2\Plastic\PlasticManager
*/
protected static function getFacadeAccessor()
{
Expand Down
6 changes: 6 additions & 0 deletions src/Fillers/EloquentFiller.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function fill(Model $model, Result $result)
* @param $model
* @param array $hit
*
* @throws \ReflectionException
*
* @return static
*/
public function fillModel(Model $model, $hit = [])
Expand Down Expand Up @@ -82,6 +84,8 @@ public function fillModel(Model $model, $hit = [])
* @param array $attributes
* @param Relation $parentRelation
*
* @throws \ReflectionException
*
* @return mixed
*/
public function newFromBuilderRecursive(Model $model, array $attributes = [], Relation $parentRelation = null)
Expand All @@ -105,6 +109,8 @@ public function newFromBuilderRecursive(Model $model, array $attributes = [], Re
* Get the relations attributes from a model.
*
* @param \Illuminate\Database\Eloquent\Model $model
*
* @throws \ReflectionException
*/
protected function loadRelationsAttributesRecursive(Model $model)
{
Expand Down
Loading