I want to use the standard site search but much prefer that (first) part word search is in place by default. By this I mean if a user searches for dog they will also find dogs, so the term Craft uses would then be dog*.

My strategy would then be to take the search string (e.g. 'dog fee') and remove any commas or fullstops unless the string is in quotes ("dog fee"). I would then split the string using spaces and throw away any empty strings ('dog', 'fee'), and then append the * to each word and send 'dog* fee*' to the search system.

Is this the best approach to get what I want, or have I missed a glaringly obvious and easy way of doing it?

1 Answer 1


This sounds like a good approach and could be done using a twig filter on your search string.

Here are the first two lines of the example from the docs:

{% set query = craft.request.getParam('q') %}
{% set entries = craft.entries.search(query|customFilter).order('score') %}

In this example query is now modified by customFilter and can be updated in your Twig filter to behave however you like.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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