Search Function

Permalink 1 user found helpful
Is there a way to make a search block search only for whole words? An example would be when a user searches for Sign, they get a results page that shows results like:

designed
Signal
Signature

etc...

Because sign is in the word.

 
Steevb replied on at Permalink Reply
Steevb
Our search block does what you ask.

I search for 'and', I get 'Broadband', 'Handy' and 'Sandra'.

Does yours not do that?
Wrdslngr123 replied on at Permalink Reply
I do get the word I search, but I get every instance of it (even when it's within another word).

Go here and search something like Sign or Hammer and you can see what it does. If there was a way to have it search only for whole words, that would do it. I just don't know how to make the search work that way.

http://www.thereianetwork.com/concrete5.4.2.1/index.php?cID=1...
beebs93 replied on at Permalink Reply
beebs93
IIRC, the search block looks at page content, description, title and author for anything *like* the search terms entered (not exact) hence getting results like you're describing.

You would have to override the search block's default controller to change how it searches for results.

That said, why would you prefer to search only exact matches? Doesn't that defeat the purpose of what a site-wide search is meant for?

If I search for "sign" but pages with "signs" are omitted I'd say I'm getting screwed.
PatrickHeck replied on at Permalink Best Answer Reply
PatrickHeck
Wrdslngr123, if you change the search behaviour from SimpleIndexMode to sortByRelevance it will only search for complete word by default. To do this put a copy of /concrete/blocks/search/controller.php in /blocks/search/controller.php and find and delete the following line:
$ipl->setSimpleIndexMode(true);

then instead add this line:
$ipl->sortByRelevance();


To get meaningful results though you should edit your stopwords file. See here for more information: http://www.concrete5.org/community/forums/customizing_c5/sort-searc...
Wrdslngr123 replied on at Permalink Reply
That's what I needed. Thanks!