Closed mgburns closed 6 years ago
For backwards compatibility we could do something like this:
$default_operator = ( isset( $plugin_s4wp_settings['s4wp_default_operator'] ) ) ? $plugin_s4wp_settings['s4wp_default_operator'] : 'OR';
$facet_operator = apply_filters( 'solr_facet_operator', $default_operator );
and then use $facet_operator
instead of $default_operator
in the return statements of parse_facets
.
This would allow you to change the facet operator with a filter without changing existing functionality for those not expecting the change.
Would that work for you @mgburns?
Totally! Thanks @ataylorme.
@mgburns feel free to make a PR, especially if you are participating in Hacktoberfest, otherwise, I'll make a PR when I have some time next week.
@ataylorme Wait, I can get a free T-Shirt?? Count me in! :)
In line 436 of
class-solrpower-wp-query.php
the default query operator is used to join facet clauses.This feels conflated to me, as the search operator for multi-word queries feels very different than the search operator for facet queries. Take the following psuedo-query:
Query:
how do I apply to college
filtered by post typefaq
from date2018
.If the default search operator is
OR
, then it will find posts that have any of the query words present, that have either a post type offaq
or were published in2018
.In our UI, and for most I would imagine, I would expect the filters to be joined with an
AND
instead of anOR
, but I also don't want to be overly strict with multi-phrase query terms.I'd think the default join op for facets should be
AND
(perhaps filterable withapply_filters
).