I have the following text search input field:
<form action="{{ url('search') }}">
<input type="search" name="q" placeholder="Search">
</form>
I would like to search each keyword in the user's query with the OR logic as per Craft docs.
salty OR dog containing either “salty” or “dog” (or both).
How can I separate the user's text search for "salty dog" so that the search query returns results for "salty" or "dog" instead of only for results containing "salty dog"?
Below is how I currently have the search set up in the template:
{% set query = craft.request.getParam('q') %}
{% set entries = craft.entries.search('*' ~ query ~ '*').order('score') %}
{% paginate craft.entries.search('*' ~ query ~ '*').limit(10).order('score') as pageInfo, pageEntries %}
I have fuzzy search enabled via config:
'defaultSearchTermOptions' => array(
'subLeft' => true,
'subRight' => true,
),