From 8768fec36adb79f2d7fc38f8dced249adfa8746c Mon Sep 17 00:00:00 2001 From: Asim Liaquat Date: Fri, 21 Jul 2017 11:59:53 +0100 Subject: [PATCH] Added ids query --- .../Elasticsearch/Gateway/AbstractGateway.php | 7 ++ .../Pimcore/Elasticsearch/Query/IdsQuery.php | 75 +++++++++++++++++++ .../Elasticsearch/Query/QueryBuilder.php | 7 ++ 3 files changed, 89 insertions(+) create mode 100644 lib/Byng/Pimcore/Elasticsearch/Query/IdsQuery.php diff --git a/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php b/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php index d24a7b8..0815f7f 100644 --- a/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php +++ b/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php @@ -187,6 +187,13 @@ protected function processQuery(QueryInterface $query) ]; break; + case "ids": + $result["ids"] = [ + "type" => $query->getIndexType(), + "values" => $query->getValues() + ]; + break; + case "prefix": $result["prefix"] = [ $query->getField() => $query->getQuery() diff --git a/lib/Byng/Pimcore/Elasticsearch/Query/IdsQuery.php b/lib/Byng/Pimcore/Elasticsearch/Query/IdsQuery.php new file mode 100644 index 0000000..0c2d5b6 --- /dev/null +++ b/lib/Byng/Pimcore/Elasticsearch/Query/IdsQuery.php @@ -0,0 +1,75 @@ + + */ +final class IdsQuery implements QueryInterface +{ + /** + * @var string + */ + private $indexType; + + /** + * @var array + */ + private $values; + + /** + * IdsQuery constructor. + * + * @param string $indexType + * @param array $values + */ + public function __construct($indexType, array $values) + { + $this->indexType = $indexType; + $this->values = $values; + } + + /** + * Get type + * + * @return string + */ + public function getIndexType() + { + return $this->indexType; + } + + /** + * Get values + * + * @return array + */ + public function getValues() + { + return $this->values; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return "ids"; + } + +} diff --git a/lib/Byng/Pimcore/Elasticsearch/Query/QueryBuilder.php b/lib/Byng/Pimcore/Elasticsearch/Query/QueryBuilder.php index 6f8f654..692d9c7 100644 --- a/lib/Byng/Pimcore/Elasticsearch/Query/QueryBuilder.php +++ b/lib/Byng/Pimcore/Elasticsearch/Query/QueryBuilder.php @@ -262,6 +262,13 @@ protected function processQuery(QueryInterface $query) ]; break; + case "ids": + $result["ids"] = [ + "type" => $query->getIndexType(), + "values" => $query->getValues() + ]; + break; + case "prefix": $result["prefix"] = [ $query->getField() => $query->getQuery()