-
Notifications
You must be signed in to change notification settings - Fork 4
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
Possibility to use tags on filters #19
Comments
I think that creating an extra property on the query object beside |
Hi @RozbehSharahi, thanks for the suggestion! I'm not aware there's an alternative way to tag and exclude. Technically, we could go with an extra property, but also it would not be complicated to take top level filter criteria that is combined with logical AND and pass it through multiple I think the main challenge here is to come up with PHP API that would be simple to use, and also compatible with the current semantics. Thinking a little bit about it, one other approach would be to go for a method on the Query object that would work with public function tagFilter(Criterion $criteria, string $tag): void;
$query->tagFilter($criteria, $tag); If you could suggest/mock an API, I think it would be a good way to get this started. |
/cc @adamwojs |
@pspanja Hello, i agree that using this should be as simple as possible. Taking the top level filter is not that easy, because the solr bundle will add a couple of other conditions to the query which results into following:
This means the conditions are actually not the top level criteria and we never know how many criteria were added before by the framework. It sound very fragile to me. What I did on the current project im working on is to add a new field called And instead of directly setting a list of criterion i set a new class that i created called FacetFilter consists of two properties: tag and criterion. And of course i had to extend NativeQueryConverter and add the FacetFilter class. This is the code:
// FacetFilter class:
And finally this is how you use it:
This is what i made to make it fast work for our project. In fact though if i would create a PR on ezpublish-kernel I would suggest a different method, that is cleaner in my opinion. I split that in a separated comment since this is not an easy topic. |
Plan of attackConstraints:
The idea of tagging is only interesting to bind a facet to a filter. In order to keep this in sync that facet should actually contain a corresponding filter/criterion. Code wise this means:
So in order to use facetBuilders we do now following:
This way the facetBuilder is directly related to it's corresponding criterion and we can build stuff like:
Or range facets, ... In my opinion this is very extendible. Will not need many changes on ez core classes. The user/developer doesn't even need to define a tag since as you mentioned we could use spl_object_hash but since we are in the scope of a facetBuilder we can simply use the name, which is much easier to debug when debugging the solr queries. The good thing is: FacetBuilders are AFAIK not available on EZ-Legacy-SQL-Driver which would keep this still agnostic. In fact it would even be possible to implement SQL facets as well and the pattern should be perfectly fine for that. Action Items:
|
Ok i just saw that there is even already a $filter on FacetBuilder :) Maybe this can be achieved as well without adding the $values property actually. |
Hello,
i would actually write this on https://github.com/ezsystems/ezplatform-solr-search-engine but unfortunately the issue board is turned off there and the creating the pull-request for that is maybe to early.
It seems though that this problem also exists with your extra bundle.
When trying to exclude filters from facets in order to have f.i. multi-select facets i realized that it is not possible with the current implementation of ezplatform-solr-bundle.
Normally you would do that by tagging your filters and excluding them on the facet, see:
http://yonik.com/multi-select-faceting/
Unfortunately the solr bundle is just sending the whole query as one long query string:
fq=
{!lucene}bla:123 AND (bar:123) AND (foo:333)
which makes tagging impossible as far as I know, because this could only be achieved like follwoing:
The idea of having an agnostic data-layer where you can use solr as if it was a SQL Database conflicts with this since queries are nested as you would like to:
AND (OR (AND bar=1)))
I am not an expert on solr or maybe there is another way to exclude filters on facets which i am not aware of.
Do you have experience with that? Or is this to be considered a real issue?
Kind regards
Robert (Rozbeh Chiryai Sharahi)
The text was updated successfully, but these errors were encountered: