php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68683 Allow individual filters to be removed
Submitted: 2014-12-29 12:16 UTC Modified: 2015-01-11 04:22 UTC
From: marcel at berteler dot co dot za Assigned:
Status: No Feedback Package: sphinx (PECL)
PHP Version: 5.4.36 OS: Linux
Private report: No CVE-ID: None
 [2014-12-29 12:16 UTC] marcel at berteler dot co dot za
Description:
------------
When doing multiple queries with a few filters that all queries share it is really useful to be able to remove a specific filter. In order for this to work, the setFilter* functions should return the key of the internal array used to store the filters. An additional function ClearFilter which takes the array key as a parameter can then be used to clear a specific filter.

Test script:
---------------
// set various filters
$this->sphinxSearch->setFilter('facility_id', array($facility_id));

// apply additional filter to only include services without exceptions
$filterKey1 = $this->sphinxSearch->setFilter('exc', array(0));

// run first query
$servicesCorrectCount = $this->sphinxSearch->search($this->query);

// now remove those filters
$this->sphinxSearch->clearFilter($filterKey1);

// apply filter to only count services with exceptions
$filterKey2 = $this->sphinxSearch->setFilter('exc', array(1));

// run second query
$servicesExceptionCount = $this->sphinxSearch->search($this->query);



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-29 13:17 UTC] tony2001@php.net
-Status: Open +Status: Feedback
 [2014-12-29 13:17 UTC] tony2001@php.net
Since we use libsphinxclient, the filters are not stored using an array.
Instead, setFilter() calls sphinx_add_filter() function which returns bool (see sphinxclient.c in libsphinxclient).
In addition to this function, libsphinxclient provides sphinx_reset_filters() function, which is used in resetFilters() method.
There is no sphinx_remove_filter() function, unfortunately, therefore I don't think such function can be implemented in PHP extension.
 [2014-12-30 06:50 UTC] marcel at berteler dot co dot za
I understand now. The request to add these functions should therefore be directed to the sphinx team. I see that internally the libsphinxclient does keep track of the number of filters applied so in theory it must be possible to remove a specific filter if the libsphinxclient would return a filter index upon adding a filter.
 [2015-01-11 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC