Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Search Specifications- Multiple Search Fields?

Quote Reply
Search Specifications- Multiple Search Fields?
Hi:

I have a mini-search form on all my pages. To make it work better for my use, I have included a drop-down list so you can search for the term, or search specific fields for that term. One of the specified fields is "Title".

As my site has grown, I see the need to widen that search. I have found that just "Title" is not enough. Many times, the "Title" is in a foreign language, and I have created fields for Alternate spellings... or English Translations.

So I would like the specific "Title" search to also search these related fields.

Here is the code I use now:

if ($IN->param('select') =~ 'Titles') {
print "Location: http://www.bcdb.com/bcdb/search.cgi?query=&Title=$query&bool=or&substring=0\n\n";
}

If I want "$query" to search on "Title", "For_Title" and "Alt_Title", how should I do that? Can I just do this:

if ($IN->param('select') =~ 'Titles') {
print "Location: http://www.bcdb.com/bcdb/search.cgi?query=&Title=$query&For_Title=$query&Alt_Title=$query&bool=or&substring=0\n\n";
}

Thanks!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Search Specifications- Multiple Search Fields? In reply to
Hi,

Mmm.. I'm not sure to be honest. I would imagine:

print "Location: http://www.bcdb.com/bcdb/search.cgi?query=&Title=$query&For_Title=$query&Alt_Title=$query&bool=or&substring=0\n\n";

..would actually try and match the resullts from all of those fields - I could be wrong though (never actually tried to do what your suggesting =))

Does it look like it works?

You can test, by doing different searches, i.e:

http://www.bcdb.com/bcdb/search.cgi?query=&For_Title=$query&bool=or&substring=0

http://www.bcdb.com/bcdb/search.cgi?query=&Alt_Title=$query&bool=or&substring=0

http://www.bcdb.com/bcdb/search.cgi?query=&Title=$query&bool=or&substring=0

?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Search Specifications- Multiple Search Fields? In reply to
OK, I ran a test. A cartoon "Weiss Kreuz" has that for it's title. The English translation is "White Cross".

I ran an all fields test search for
"White Cross", and that cartoon came up. I searched "White Cross" for title field only, NO HITS. Cool.

I then changed my code to:

if ($IN->param('select') =~ 'Titles') {
print "Location: http://www.bcdb.com/bcdb/search.cgi?query=&Title=$query&Eng_Title=$query&Alt_Title=$query&For_Title=$query&Series_Title=$query&bool=or&substring=0\n\n";
}

and searched
"White Cross"- NO hits.

So that does NOT work.

dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Search Specifications- Multiple Search Fields? In reply to
Hi,

There isn't really any simple solution I can think of I'm afraid :(

The only way I can see it working - is actually doing a "search" with the different paramaters, to see if they do actually give any results. This could get quite messy though, as it would require re-invoking a search (not as simple as just calling a basic "search", and checking the results were found - you need to do it similar to how I do it in NewSearchResults.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Search Specifications- Multiple Search Fields? In reply to
OK... I will not worry about it for now.
Thanks Andy!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Search Specifications- Multiple Search Fields? In reply to
Here are some tips:

1) Use print $IN->redirect($url) instead
2) The url shouldn't be html escaped (ie. & instead of & or just use semi-colons [;])
3) You should url escape the values (eg. "Title=" . $IN->escape($query))
4) No need for the regex on the if statement - if ($IN->param('select') eq 'Titles') {

Adrian