Working on a new site in dev and have some content setup. Testing searches and it looks like partial searches like searching for appl instead of apple returns no results.  Is there a switch or optional module I need to use?

Thanks.

Most helpful answers

Alternatively, you could set up your search using Views and the "Combine fields filter":

  • Build a Views page, add a path (e.g. my-custom-search) and add the fields you're interested in (e.g. Title, Body, Tags)
  • To make the Combine fields filter work with the Tags field, you must provide the name of terms (instead of just IDs):
    • add a relationship to "Content: Tags (field_tags)"
    • add the field "Taxonomy term: Name", using the relationship
  • In the section Filter Criteria, add "Global: Combine fields filter".
  • Expose the filter to visitors, choose the operator "Contains", and choose your fields to combine for filtering.
  • Go to the page, and test the filter / search. It should find partial words.

I use this approach on two sites. It works very well, and it's even quite fast. To complete the search functionality, I've added a block display to the view, more or less configured as the page display.

Backdrop core doesn't provide this currently, though there's an open issue for it: https://github.com/backdrop/backdrop-issues/issues/1320

Unfortunately I don't think PorterStemmer will work in this case as I believe it only matches partial, real words (e.g. 'apples' -> 'apple', but not 'appl').

You might have luck with something like Search API: https://github.com/backdrop-contrib/search_api but I've not tried it myself, and there might be another contrib module you need that adds 'fuzzy' search ability...

Comments

Backdrop core doesn't provide this currently, though there's an open issue for it: https://github.com/backdrop/backdrop-issues/issues/1320

Unfortunately I don't think PorterStemmer will work in this case as I believe it only matches partial, real words (e.g. 'apples' -> 'apple', but not 'appl').

You might have luck with something like Search API: https://github.com/backdrop-contrib/search_api but I've not tried it myself, and there might be another contrib module you need that adds 'fuzzy' search ability...

ericfg's picture

I had no idea that porter stemmer had that limitation. thanks

Olafski's picture

Alternatively, you could set up your search using Views and the "Combine fields filter":

  • Build a Views page, add a path (e.g. my-custom-search) and add the fields you're interested in (e.g. Title, Body, Tags)
  • To make the Combine fields filter work with the Tags field, you must provide the name of terms (instead of just IDs):
    • add a relationship to "Content: Tags (field_tags)"
    • add the field "Taxonomy term: Name", using the relationship
  • In the section Filter Criteria, add "Global: Combine fields filter".
  • Expose the filter to visitors, choose the operator "Contains", and choose your fields to combine for filtering.
  • Go to the page, and test the filter / search. It should find partial words.

I use this approach on two sites. It works very well, and it's even quite fast. To complete the search functionality, I've added a block display to the view, more or less configured as the page display.

mazze's picture

Thank you @olafski... I just wanted to write a similar answer. However, here's a demo on a live site

https://landwirtschaft.ag/search?combine=apfe

("apfe" also finds "apfel", german word for "apple")

Using Views for search a some other advantages: you can include any filter that Views offers. If you want e.g. only arcticles with have an "a" in the title, or within a certain time rang... simply set a filter:-)

Thanks everyone for the quick responses. Great community here.