diff --git a/composer.json b/composer.json index 569edbf..7695fa9 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "byng/pimcore-elasticsearch-plugin", "description": "Elasticsearch Pimcore plugin", - "version": "2.3.0", + "version": "2.4.0", "type": "pimcore-plugin", "license": "MIT", "keywords": [ "pimcore", "elasticsearch", "plugin" ], diff --git a/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php b/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php index e5ec7ee..ebec556 100644 --- a/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php +++ b/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php @@ -16,6 +16,7 @@ use Byng\Pimcore\Elasticsearch\Model\ResultsList; use Byng\Pimcore\Elasticsearch\Query\BoolQuery; use Byng\Pimcore\Elasticsearch\Query\MatchQuery; +use Byng\Pimcore\Elasticsearch\Query\TermsQuery; use Byng\Pimcore\Elasticsearch\Query\Query; use Elasticsearch\Client; @@ -218,6 +219,11 @@ protected function processQuery(Query $query) "operator" => $query->getOperator() ]; break; + case "terms": + /** @var TermsQuery $query */ + $result = []; + $result["terms"][$query->getField()] = $query->getTerms(); + break; case "range": $result = []; $result["range"][$query->getField()] = $query->getRanges(); diff --git a/lib/Byng/Pimcore/Elasticsearch/Query/TermsQuery.php b/lib/Byng/Pimcore/Elasticsearch/Query/TermsQuery.php new file mode 100644 index 0000000..bb062ae --- /dev/null +++ b/lib/Byng/Pimcore/Elasticsearch/Query/TermsQuery.php @@ -0,0 +1,74 @@ + + */ +final class TermsQuery implements Query +{ + /** + * @var string + */ + private $field; + + /** + * @var array + */ + private $terms; + + /** + * TermsQuery constructor. + * + * @param string $field + * @param array $terms + */ + public function __construct($field, array $terms) + { + $this->field = $field; + $this->terms = $terms; + } + + /** + * Get field + * + * @return string + */ + public function getField() + { + return $this->field; + } + + /** + * Get query + * + * @return array + */ + public function getTerms() + { + return $this->terms; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return "terms"; + } +}