Gossamer Forum
Home : Products : DBMan : Customization :

Searching for Multiple Keywords - Why Not?

Quote Reply
Searching for Multiple Keywords - Why Not?
Hi,

From my searching of the DBMan forums, it seems as if searching for multiple items is not (yet) possible. I've taken some stabs at changing that but thusfar have had no success. I'm wondering why it is not possible, when it will be, if the SQL version alleviates this problem and/or if anyone has had any luck making such searches work.

We have a database set up at:
www.eTeach.net/calendar.html

When I try a keyword search or an Advanced Search using the match any checkbox for:
"forest wetlands"
I get "Search Failed" message, even though there is an entry with both terms in the description field. (search for: Belanger Creek to see the record).

------------------
farlane aka andrew mcfarlane
www.leelanau.com/pages/farlane/

Quote Reply
Re: Searching for Multiple Keywords - Why Not? In reply to
Try adding a hidden field to your keyword search form

<input type="hidden" name="re" value="on">

Then, when you want to do an "or" search, use a | character between the terms. For example

forest|wetlands

You can try it in your advanced search. Enter

forest|wetlands

in your keyword field and select the "Regular Expression" checkbox.

You can make it so people can enter either "forest wetlands" or "forest or wetlands" and get the same results. I think it's wiser to do the "forest or wetlands" format, because that way people can still search for phrases. If you make "forest wetlands" an "or" search, and they only want records that have the phrase "forest wetlands," they'll get frustrated. (At least I do.)

To do all this, you just need to add a little code to sub query in db.cgi. To allow searches in the form of "forest or wetlands"

after
local (%sortby);

add

Code:
foreach $column (@db_cols) {
if ($in{$column} =~ / or /) {
$in{$column} =~ s/ or /\|/;
$in{'re'} = 'on';
}
}
if ($in{'keyword'} =~ / or /) {
$in{'keyword'} =~ s/ or /\|/;
$in{'re'} = 'on';
}


------------------
JPD