Forgot password?
Welcome to our site!
Or Join with FTTF

Searching with plurals


I need to make sure that search results come up regardless weather the user searches for a singular or plural version of a word.

Currently a search for "penguin" will not return a post with "penguins" in it.

I've found this function which seems to work well, and handle some english irregularites, which I am going to try and use, but it would be great if this could be an official feature.
asked April 6, 2011 at 4:35 PM


2 Answers

Best answer
I fixed this by including a pluralize function, and a line of code in


$this->term = $this->oRequest['q'];

$this->oRequest['q'] = Inflect::pluralize($this->oRequest['q'])." ".Inflect::singularize($this->oRequest['q']);

This has the effect of searching for both the plural and singular version of a word, while still showing the user only the word the they typed in.

Inflect class here:
Edited April 13, 2011 3:16 pm CDT
answered April 11, 2011 at 8:36 AM
I realized that Lucene would be a more correct way to do this, but I needed a fix now.
Apr 11 '11 at 8:37
Interesting. I'll check to see if this could be added to the package.
Apr 11 '11 at 8:44
I understand you looking for advanced search features. We use MySQL's full text search as a search provider. It's not advanced but the easiest to implement, it just works with no configuration, no learning curve.

If you really need all the advanced search options then you'll have to wait untill I add Lucene support or some other search provider.

In the past I used Mnogosearch as search provider. It has many advanced features you want but very difficult to configure, so if you intersted you can look at and see if you want to write a class that uses it as search provider here.

answered April 6, 2011 at 4:48 PM

Your answer

Join with account you already have