Skip to content
Snippets Groups Projects
Commit 581a639e authored by Simonas Šerlinskas's avatar Simonas Šerlinskas
Browse files

added endpoint parameters setters

parent 3c47169d
No related branches found
No related tags found
No related merge requests found
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment