Jump to content

Suggestion: Automatically ignore words smaller than min allowed in search instead of breaking with an error


Washerhelp

Recommended Posts

Currently the ip board defaults to a minimum of 4 characters for search. This may be a due to limitations in MySQL full text search but it breaks search for many thousands of people by returning an error and makes our sites very unfriendly places to search.

Typically, many or most people these days search for phrases or ask questions. It's highly successful in Google to simply ask a question and it's my main method of searching. Many of these phrases or questions will contain some words using less than the 4 allowed. So instead of returning a failed search with an annoying and potentially confusing error - why not just ignore any words below the minimum characters and at least return results with the other words a user searched for?

For example: The following, perfectly legitimate real-world searches on this IPS Community just fail with an error message in a red box.

  • how can i upgrade my ips board?
  • how much does it cost to buy ip.board?
  • what is ip.content?


These are searches from people interested in buying. Similar searches on my ip.board and every one else's result in the same disappointing results. We all know people soon get frustrated and go elsewhere don't we?

So instead of frustrating our users, can't the search simply ignore all words below the threshold and return at least some results?

The results page could still have an advisory box saying that certain words were not used in the search.

So now searches for the three examples I mentioned will all produce some results and the advisory box can subtly inform and educate users that they need to use words longer than 4 (or whatever it's been customised to) letters.
Link to comment
Share on other sites

Just as an addendum, here are some of the recent real searches people did on my main washing machine help site, which would have all failed in my forum search with the default minimum 4 character minimum restriction -

hoover quattro ws1300 fails to fast spin
how to retrieve an underwire from tub
bad smells in washing machines
eco balls
washing machine belt off
how to find brushes
haus mw 1050
fabric conditioner doesn't get taken
indesit w1xe167 door locked and no power
1940 house rainwater and soil pipes
washing machine power but no light
drum out of balance
NTC
powder stays in tray
machine will sometimes not finish spinning
Where is filter for hotpoint wdl540 located
AQUALTIS ERROR CODE F5
LG F1256 QD
washing machine just keeps running on its own
descaleor for wirlpool
service wash once a month
Fills but not washing
trips rcd
what is a pressure switch
not enough water was going into machine

Link to comment
Share on other sites

We have our minimum set to 2 characters (using Sphinx) so the problem isn't as bad for us, but I agree that this would be an excellent change. Is there some kind of complication in the implementation that we aren't thinking of? It seems like it should be straightforward.

Link to comment
Share on other sites


I see that you've simply used all of Invision's code in there: why not just modify the search term and then call back to parent::searchResults()?




yes you are right, that worked on my localhost but not on my live board for some reason.
I will check later why it doesn't work on my live board.
Link to comment
Share on other sites

I stripped it down to just:


class ignoreSearchWords extends (~extends~)

{   

  public function searchResults()

{

  /* Search Term */

  $_st		  = $this->searchController->formatSearchTerm( trim( $this->request['search_term'] ) );


	    // Split words by space

	    $search_term	  = explode(' ', preg_replace( '#(^|s)(+|-|||~)#', " ", $_st['search_term'] ) );


	    $isFirst = true;

	    foreach ($search_term as $aKey => $aValue) {

		    if (strlen($aValue) >= $this->settings['min_search_word']) {

			    if ($isFirst) {

				    $sOutput = $aValue;

			    } else {

				    $sOutput .= ' '.$aValue;

			    }

			    $isFirst = false;

		    }

	    }

	    $this->request['search_term'] = trim($sOutput);

	    parent::searchResults ();

    }

}


The has the disadvantage of displaying only the shortened search term to the user, but for me that's an acceptable compromise to make sure it plays nicely with any changes Invision makes to that function later on. For example, if you search eGullet for "I want a burger" now, it will display the results with the statement "Your search for the term want burger returned 1000 results". Not great, but OK.

Link to comment
Share on other sites

it will display the results with the statement "Your search for the term want burger returned 1000 results". Not great, but OK.



Aha, well i dont think many members will see that actually.


to make sure it plays nicely with any changes Invision makes to that function later on.




Then it is already updated with a parent method :P
Link to comment
Share on other sites

Just installed it. It seems to work :) I can now search for - what is a pressure switch and instead of getting an error it produces 65 results. Not sure if I installed it right though because I couldn't carry out all the instructions in the hook


Install Hook:

Go to ACP > System > Applications & Modules > Manage Hooks > "Create Hook" and select (EJ33) Ignore Small Search Words.xml


I installed it by clicking install hook and pointing it to the file. But when I tried to carry out the second half of the instructions ""Create Hook" and select (EJ33) Ignore Small Search Words.xml" I only saw a form with blank fields as if editing the hook. I couldn't "select" anything.

Anyway I left it at that and as I say it appears to work. Many thanks for the fix.

Link to comment
Share on other sites


Good suggestion. Included in 3.3.3.




Great!! Its alot better to get some kind of results instead of an error page telling you that some of your search words are to short.. and then trying to come up with some kind of search term for what you actually want.. never turns out the way you want it.. = Specially, when you are trying to find a specific error that your own site gets,, and it has one or two words that around 2-3 letters... and when its set to min of 4 letters.. the search just fails instead of giving you something related to what you are searching for..
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...