- Issue created by @j. ayen green
- Status changed to Fixed
6 months ago 8:29pm 19 May 2024 - 🇦🇹Austria drunken monkey Vienna, Austria
Thanks for pointing me to that old issue, seems I overlooked it.
Regarding your question, it would be important to know if you’re talking about a programmatic search, or configuring this in Views (or similar).
In the former case, you can simply set an array-valued structure as the query keywords, as described in the doc comment of\Drupal\search_api\ParseMode\ParseModeInterface::parseInput()
. Something like this should work for your second scenario:$query->keys([ '#conjunction' => 'AND', // ALL: [ '#conjunction' => 'AND', 'red', 'white', 'blue', ], // ANY: [ '#conjunction' => 'OR', 'pizza', 'beer', ], ]);
If either “ALL” or “ANY” are empty, simply omit the respective array.
In the latter case, you can just add two “Search: Fulltext search” filters, one with operator “Contains all of these words” and one with “Contains any of these words”. If we did our job right, this should already work as expected. (Except if you try to use different searched fields for the two filters, then all bets are off.)
(You can also try doing that and looking at the keywords structure that is internally generated for this configuration.) Automatically closed - issue fixed for 2 weeks with no activity.