0

We have a Search API View (Solr) using facets and our nodes have two separate fields for the facets. One is an address field and the facet is built on the address US States and the other field is a text select list with values Virtual, Physical, National.

We need to build the facets in a way to allow the user to select a US State from facet 1 which narrows the results to node from that state.

Then, we need the second facet to also include nodes tagged as National even if they are not in the US state selected in the first facet.

It seems that the facets always narrow the results and I cannot find a way to make the facets work together as "this facet OR this other facet".

1 Answer 1

0

Search API "Or" Facet

I haven't tried this myself but there seems to be a Backend Search API feature search_api_facets_operator_or that fits with your description, although I don't know if it's available in all Drupal versions:

Search API Server backends and features

Regular Views Filters Or

Under "Filter criteria" in your views there is a dropdown arrow next to the "Add" button.

When you click it you will be able to see the And/Or Rearrange. This will open up the interface to group your filters into different groups (if necessary) and to change the Operator from And to Or.

3
  • Thank you for the reply and I wish it was that easy but this is referring to Search API facets and not Views filters so this solution does not work for this case. Mar 24, 2023 at 20:24
  • Ah, right, it's been a while since I played with Search API and it didn't register. I'll adjust my answer.
    – prkos
    Mar 24, 2023 at 20:38
  • Thank you, I'll look through the doc you linked to (hadn't seen that one yet) but I have been experimenting with using search_api_query_alter() and it seems that the conjunction is locked at "AND" and I haven't been able to override that via code. Thanks again. Mar 24, 2023 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.