From 581a639e900ee05f1b3230f2eb8077dd48b0a7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= <simonas.serlinskas@nfq.com> Date: Tue, 11 Aug 2015 16:52:12 +0300 Subject: [PATCH] added endpoint parameters setters --- src/Search.php | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/Search.php b/src/Search.php index b4196a7..805e35a 100644 --- a/src/Search.php +++ b/src/Search.php @@ -15,6 +15,7 @@ use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; use ONGR\ElasticsearchDSL\Filter\BoolFilter; use ONGR\ElasticsearchDSL\Highlight\Highlight; use ONGR\ElasticsearchDSL\Query\BoolQuery; +use ONGR\ElasticsearchDSL\SearchEndpoint\AbstractSearchEndpoint; use ONGR\ElasticsearchDSL\SearchEndpoint\AggregationsEndpoint; use ONGR\ElasticsearchDSL\SearchEndpoint\FilterEndpoint; use ONGR\ElasticsearchDSL\SearchEndpoint\HighlightEndpoint; @@ -137,6 +138,18 @@ class Search unset($this->endpoints[$type]); } + /** + * Sets parameters to the endpoint. + * + * @param string $endpointName + * @param array $parameters + */ + private function setEndpointParameters($endpointName, array $parameters) { + /** @var AbstractSearchEndpoint $endpoint */ + $endpoint = $this->getEndpoint($endpointName); + $endpoint->setParameters($parameters); + } + /** * Adds query to the search. * @@ -166,6 +179,20 @@ class Search return $endpoint->getBool(); } + /** + * Sets query endpoint parameters. + * + * @param array $parameters + * + * @return $this + */ + public function setQueryParameters(array $parameters) + { + $this->setEndpointParameters(QueryEndpoint::NAME, $parameters); + + return $this; + } + /** * Adds a filter to the search. * @@ -199,6 +226,20 @@ class Search return $endpoint->getBool(); } + /** + * Sets filter endpoint parameters. + * + * @param array $parameters + * + * @return $this + */ + public function setFilterParameters(array $parameters) + { + $this->setEndpointParameters(FilterEndpoint::NAME, $parameters); + + return $this; + } + /** * Adds a post filter to search. * @@ -232,6 +273,20 @@ class Search return $endpoint->getBool(); } + /** + * Sets post filter endpoint parameters. + * + * @param array $parameters + * + * @return $this + */ + public function setPostFilterParameters(array $parameters) + { + $this->setEndpointParameters(PostFilterEndpoint::NAME, $parameters); + + return $this; + } + /** * Adds aggregation into search. * -- GitLab