From 8766cd605da6ed0e70d5bbfa4d7e34bc2c03df13 Mon Sep 17 00:00:00 2001 From: Ioannis Giakoumidis Date: Fri, 8 Jul 2016 12:38:05 +0100 Subject: [PATCH 1/2] Update plugin to support terms query --- .../Pimcore/Elasticsearch/Gateway/AbstractGateway.php | 9 ++++++++- lib/Byng/Pimcore/Elasticsearch/Query/TermsQuery.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php b/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php index 95e6676..2ba95fa 100644 --- a/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php +++ b/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php @@ -115,7 +115,7 @@ protected function doSearch( /** * Process a query into an array usable by Elasticsearch * - * @param Query $query + * @param QueryInterface $query * * @return array */ @@ -175,6 +175,13 @@ protected function processQuery(QueryInterface $query) $result[$column]["order"] = $order; } break; + + case "terms": + $result = []; + $result["constant_score"]["filter"]["terms"] = [ + $query->getField() => $query->getTerms() + ]; + break; default: throw new \InvalidArgumentException(sprintf( diff --git a/lib/Byng/Pimcore/Elasticsearch/Query/TermsQuery.php b/lib/Byng/Pimcore/Elasticsearch/Query/TermsQuery.php index bb062ae..e828f4b 100644 --- a/lib/Byng/Pimcore/Elasticsearch/Query/TermsQuery.php +++ b/lib/Byng/Pimcore/Elasticsearch/Query/TermsQuery.php @@ -20,7 +20,7 @@ * * @author Asim Liaquat */ -final class TermsQuery implements Query +final class TermsQuery implements QueryInterface { /** * @var string From 2fec1fdae3826196656ce047af35a5d829d71d30 Mon Sep 17 00:00:00 2001 From: Ioannis Giakoumidis Date: Fri, 8 Jul 2016 12:53:56 +0100 Subject: [PATCH 2/2] Remove extra code --- lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php b/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php index 2ba95fa..f0b4fbe 100644 --- a/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php +++ b/lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php @@ -177,7 +177,6 @@ protected function processQuery(QueryInterface $query) break; case "terms": - $result = []; $result["constant_score"]["filter"]["terms"] = [ $query->getField() => $query->getTerms() ];