-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setPostFilter method to Elastica\Query #645
Conversation
@krzaczek Can you add a second "integration" test to make sure it also works directly with ES? |
Can I add it to testSetPostQuery() test ... or do You prefer to put it in a seperate test ? |
@ruflin Added new test file Query/PostFilterTest.php and placed both tests there. Hope it's ok now. Pawel |
@@ -1,5 +1,8 @@ | |||
CHANGES | |||
|
|||
2014-07-02 | |||
- Add setPostFilter method to Elastica\Query (http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_filtering_queries_and_aggregations.html#_post_filter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One detail I forgot: Can you add the pull request Id at the end of the line. I just realized the one before is also missing. If you can add also this one, I don't mind ;-)
Done |
Add setPostFilter method to Elastica\Query
Merged. Thx. |
Don't you think this should support the setting of a post filter that extends |
Please see #669 |
According to doc: Also, the top-level filter parameter in search has been renamed to post_filter, to indicate that it should not be used as the primary way to filter search results (use a filtered query instead), but only to filter results AFTER facets/aggregations have been calculated. We should probably make setFilter deprecated and change it to: public function setFilter(AbstractFilter $filter)
{
return $this->setPostFilter($filer)
} and rewrite setPostFilter to public function setPostFilter(AbstractFilter $filter)
{
return $this->setParam('post_filter', $filter->toArray());
} or better to make it backwards compatible .. public function setPostFilter($filter)
{
if (is_array($filter)) {
return $this->setParam("post_filter", $filter);
} elseif ($filter instarnceof AbstractFilter) {
return $this->setParam('post_filter', $filter->toArray());
}
} |
Personally i prefer the non-backwards compatible solution you described since the changes are fresh. |
@ruflin What do You think ? |
As the function setFilter is used very often, I prefer the BC compatible option but we should have a way to tell the people that they are using a deprecated version (phpdoc @deprecated). Can you open a pull request with the suggestion? So we also se what kind of changes are needed on the Elastica side. |
Well the BC doesn't affect setFilter method. It always required AbstractFIlter as parameter. Only the setPostFilter required array ... and it's rather new (merged 1 month ago) so the question is shoud we change the param to AbstractFIlter for setPostFilter .. or keep it BC and allow array and AbstractFilter |
Unfortunately there was already a release in between so I would suggest to make it BC compatible for the moment but make it clear that this will not be the case in the long run and should be cleaned up later. |
OK ... i've just sent a pull request ... check it out. |
Hi,
Just added a missing method setPostFilter() that allows to set "post_filter" param to Elastica\Query object.
@see http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_filtering_queries_and_aggregations.html#_post_filter
Pawel