I have implemented the standard search form at: https://docs.craftcms.com/v2/templating/search-form.html
and added fuzzy searching:
{% set entries = craft.entries({
search: {
query: query,
subLeft: true,
subRight: true
}
}) %}
as per:
https://docs.craftcms.com/v2/searching.html
And this works well for finding entries using a single search word, even if it is misspelled.
However I need to be able to find entries that contain more than one search term, eg:
Toronto AND French
And for that I get "No results found" in search results.
Searching for "Toronto French" will result in "Your search for “Toronto French” didn’t return any results."
The page:
https://docs.craftcms.com/v2/searching.html Does describe an OR search:
salty OR dog containing either “salty” or “dog” (or both).
But I do not seem to be able to find a way to AND...
Is there a way to do this?
Much thanks ahead of time......
salty dog
-> 'containing both “salty” and “dog”.' you could maybe create your own function to parse anand
between your words but it's probably easier to use the default way without theand
-> separate your terms with a whitespace – Robin Schambach Jun 9 '18 at 17:31craft.entries.fieldHandleOne('*term*').fieldHandleTwo('*term*').all()
if your fields are known /specified. Otherwise you'll need to prepend the field handle in your search. Or you need to create a custom search – Robin Schambach Jun 10 '18 at 12:39