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

Searching with plurals

1

639 views
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.

http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
 
asked April 6, 2011 at 4:35 PM

 US

2 Answers

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

/lib/Lampcms/Controllers/Search.php

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

Add
$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:

http://kuwamoto.org/2007/12/17/i...script-and-ror/
flag
Edited April 13, 2011 3:16 pm CDT
typo
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.
flag
Apr 11 '11 at 8:37
Interesting. I'll check to see if this could be added to the package.
flag
Apr 11 '11 at 8:44
1
 
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 mnogosearch.org and see if you want to write a class that uses it as search provider here.

flag
answered April 6, 2011 at 4:48 PM

Your answer

Join with account you already have

FTTF

Preview

Alert