Gossamer Forum
Home : Products : DBMan : Customization :

Keyword Search & Multple word search

(Page 1 of 2)
> >
Quote Reply
Keyword Search & Multple word search
I want to set up a simple keyword search for users without logging in. This keyword search would search for the word in all fields. How do I set it up? I have setup a text box and a search button in a form - what should be the ACTION=" ----- " in defining this form.

Secondly, is it possible to do searches for multiple words with 'and'. How would that work.

Is there any site which has implemented this using DM Man.

Greatly appreciate if you can help.

HB
Quote Reply
Re: Keyword Search & Multple word search In reply to
Thanks a ton. It worked.

HB
Quote Reply
Re: Keyword Search & Multple word search In reply to
There is no way to do a multiple "and" search with DBMan at this time. If you enter multiple words, it will look for a phrase. I understand that the next major release will include boolean searches, but there is no projected release date.

To set up a keyword search on a static html page, use

Code:
<form action="http://server.com/cgi-bin/db.cgi" method="GET">
<input type=hidden name="db" value="default">
<input type=hidden name="uid" value="default">
<INPUT TYPE="TEXT" NAME="keyword" SIZE=15 MAXLENGTH=255> Keyword Search
<INPUT TYPE="SUBMIT" NAME="view_records" VALUE="Search">
<INPUT TYPE="RESET" VALUE="Reset">
</FORM>

Change the bolded parts above to match your database. For example, if your .cfg file is not named "default.cfg," change the default above to match the name of the database. Don't change the value of the uid field, though.


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





Quote Reply
Re: Keyword Search & Multple word search In reply to
There is a way to "and" keywords if you are interested see:

http://www.library.unsw.edu.au/~law/repsrch.html

------------------
JGU

Quote Reply
Re: Keyword Search & Multple word search In reply to
I'm not doubting that it's possible to do it in Perl. I suppose I ought to have said that I don't know how to do it in DBMan at this time. But it is supposed to be coming.


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





Quote Reply
Re: Keyword Search & Multple word search In reply to
jury is using DBMAN and the "and" search seems to work.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Keyword Search & Multple word search In reply to
I didn't realize that. Sorry.

I think it would be very nice for the webmasters of the site to share their expertise with the rest of us.


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





Quote Reply
Re: Keyword Search & Multple word search In reply to
Its a bit of a hack but I wanted to be able to search for three keywords in any order in the title field (field 1), so I made two hidden fields(2 and 3) and made the following changes in db.cgi:

sub split_decode {
# -------------------------------------------
my ($input) = shift;
$input =~ s/\Q$db_delim\E$/$db_delim /o; # Add a space if we have delimiter new line.
my (@array) = split (/\Q$db_delim\E/o, $input);

### my changes ########
@array[2]=@array[1];
@array[3]=@array[1];
### end of my changes ###########

for ($i = 0; $i <= $#array; $i++) {
$array[$i] =~ s/~~/$db_delim/og; # Retrieve Delimiter..
$array[$i] =~ s/``/\n/g; # Change '' back to newlines..
}
return @array;
}


this automaticly copies what ever you type into field 1 into the two hidden fields (2 and 3). Then just make three input boxes on your search page - one for each of the title fields (1,2,3). Rather simple but it'll work until bool comes along!


-------------------
JGU



[This message has been edited by jury (edited July 27, 1999).]
Quote Reply
Re: Keyword Search & Multple word search In reply to
I don't want to be dense, but are the two hidden fields part of you cfg file or just the input boxes on your search page?

If they are part of you cfg file, when the boolean version comes along, are you going to have to reconfigure everything? And, if they are part of your cfg file, does your actual database have two title fields with the same thing entered twice?

One last question... where in the cgi file does that go?

[This message has been edited by sigrid (edited November 10, 1999).]
Quote Reply
Re: Keyword Search & Multple word search In reply to
Yes they are in the cfg file (field_type -2). Yes when the bool comes along (Alex is a very busy person though) I'll have to open the database.db file up in Excel and delete the columns that are the duplicate fields and reconfigure the .cfg file information. It just replaces the whole "sub split_decode" sub.

------------------
JGU

Quote Reply
Re: Keyword Search & Multple word search In reply to
Thanks. I'm definitely thinkging about doing that. I didn't think about deleting fields using excel- that would make it easy.
Quote Reply
Re: Keyword Search & Multple word search In reply to
Has anyone tried this mod before? exactly what do I have to do in the *.cfg file? it doesn't state what I need to do in the *.cfg file. besides, the example site: http://www.library.unsw.edu.au/~law/repsrch.html shows two hidden fields "Hide_textA" and "Hide_textB"......does that mean I have to have two extra fields, both field has duplicated data as the "Title" field? sorry, but i don't really know exactly how things work for this one.....
Quote Reply
Re: Keyword Search & Multple word search In reply to
Just add the ##my changes## code in the
sub split_decode subroutine like the example here. Yes create hidden fields for these changes to make copies of your chosen fields into (you use the field numbers in the code - so my title field (1) is copied into both hidden fields (2) and (3). My cfg field setup is:
Code:
%db_def = (
ID => [0, 'numer', -2, 8, 1, '', ''],
Title => [1, 'alpha', 75, 255, 0, '', ''],
Hide_TitleA => [2, 'alpha', -2, 255, 0, '', ''],
Hide_TitleB => [3, 'alpha', -2, 255, 0, '', ''],
Contained_in => [4, 'alpha', 75, 255, 0, '', ''],
Call_number => [5, 'alpha', 75, 255, 0, '', ''],
Holdings => [6, 'alpha', 75, 255, 0, '', ''],
Variant_titles => [7, 'alpha', 75, 255, 0, '', ''],
Jurisdiction => [8, 'alpha', 75, 255, 0, '', ''],
Abbreviations => [9, 'alpha', '75x2', 500, 0, '', ''],
Hide_Abbrevns => [10,'alpha', -2, 500, 0, '', ''],
Notes => [11,'alpha', '75x2', 500, 0, '', ''],
URL => [12,'alpha', 75, 255, 0, '', ''],
Userid => [13, 'alpha', -1, 15, 0, '', '']
);

then look at
www.library.unsw.edu.au/~law/repsrch.html to see how i've set up my submit page.

[This message has been edited by jury (edited January 05, 2000).]

[This message has been edited by jury (edited January 05, 2000).]
Quote Reply
Re: Keyword Search & Multple word search In reply to
Why can't we use the query subroutine from the latest Links which does support BOOLEAN searches?
Quote Reply
Re: Keyword Search & Multple word search In reply to
Katana Man

That is a good suggestion. Logically speaking, you can use LINKS search.cgi script to search the DBMAN database, however, you will lose the following search options:

1) Whole Words
2) Regular Expressions
3) Range Searches (unless you mod the search.cgi script to do this)
4) Keyword search (unless you specify all fields in the database to be searched in the @search_fields array located in the links.def file)

But at least you can get the Boolean AND/OR connector option using the LINKS script.

Regards,


------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 01, 2000).]
Quote Reply
Re: Keyword Search & Multple word search In reply to
Can someone please give a more detailed procedure as to how to implement such search using part of the links script?

Quote Reply
Re: Keyword Search & Multple word search In reply to
1) Download the search.cgi script.

2) Edit the require lines:

Code:
require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";

To the following:

Code:
require "./default.cfg";
require "./db.cgi";
require "./html.pl";

Include the full ABSOLUTE PATH if need be for these files.

(Of course, the better thing to do in terms of processing is copy all the subs used in the db_utils.pl for LINKS into the search.cgi file...but most if not all the subs are located in the db.cgi file.)

2) Add the following in your default.cfg file:

Code:
@search_fields = (Field1,Field2,Field3,Field4);

Replace the Field and number with the field number of the fields that you want to search.

3) Replace all occurences of &site_html_search_success; with the following:

Code:
&html_view_sucess;

And replace all occurences of &site_html_search_failure with the following:

Code:
&html_view_failure;

4) Copy the codes from the site_html.pl in the sub site_html_search_results routine in the site_html.pl file and paste them into your sub html_view_success routine...Do the same for the sub site_html_search_failure in site_html.pl file and sub html_view_failure in the html.pl file.

5) Replace your FORM METHODS codes in your search form with the following:

Code:
<FORM METHOD=GET ACTION="search.cgi">

Replace the INPUT SUBMIT field with the following:

Code:
<INPUT TYPE="Submit" Value="Search">

You do not need to name the submit field as view_records.

That should get you started...There are probably more code hacks to add to the search.cgi...but this provides the nuts and bolts hacks that will get you started.

Good luck!

Also, remember to read my heeding advice above...you will lose some of the DBMAN search options (like Whole Words, Regular Expressions, etc.). Think very carefully about the trade-offs between using search.cgi and the emdedded query routine in DBMAN (db.cgi).

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 03, 2000).]

[This message has been edited by AnthroRules (edited March 03, 2000).]

[This message has been edited by AnthroRules (edited March 03, 2000).]
Quote Reply
Re: Keyword Search & Multple word search In reply to
For Step 3, which files should I be looking for for that string: &site_html_search_success?
Quote Reply
Re: Keyword Search & Multple word search In reply to
Uh...in the search.cgi file!

One other thing I neglected to mention in this code hack is to replace &site_html_link in the search.cgi script with &html_record.

Again...there may be other code tweaks that will have to be applied...but it should work.

Of course, another solution is to dowload the site_html_templates.html and the search template files...and simply use the LINKS search files and scripts of LINKS with your DBMAN database file.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 14, 2000).]
Quote Reply
Re: Keyword Search & Multple word search In reply to
dont' know why, but search.cgi doesn't have &site_html_serach_success!

it only has &site_html_search_failure
Quote Reply
Re: Keyword Search & Multple word search In reply to
Oops...I meant &site_html_search_results; rather than &site_html_search_success;.

Sorry about that.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Keyword Search & Multple word search In reply to
Wouldn't it be possible, Eliot, to use all of DBman's search controls, while at the same time utilizing search.cgi's boolean search?

If you write up a html file to make the calls, that is...

Code:
<P><FORM ACTION="db.cgi" METHOD="GET">
<INPUT TYPE="TEXT" NAME="keyword" size=38 maxlength=255> Keyword search
<input TYPE="SUBMIT" NAME="view_records" VALUE="GO!">
</FORM></P>

<P>FORM ACTION="search.cgi" METHOD="GET">
<INPUT TYPE="TEXT" NAME="keyword" size=38 maxlength=255> Boolean search (and/or)
<input TYPE="SUBMIT" NAME="view_records" VALUE="GO!">
</FORM></P>

Of course the above could be modified to do any other sort of dbman search (whole words, reg. exp., etc.) I don't think that's the correct syntax for search.cgi, but you get the idea. Smile

That way, on the same page, you could make calls to both db.cgi search patterns as well as search.cgi search patterns.

Would that work? Or am I dreaming? Smile


------------------
----------------------------------------
Lee Leisure
HP Customer Relations Manager
----------------------------------------
* NOTE: This message is intended
for personal purposes only, and does
not imply the position or opinion of
the Hewlett Packard Company.


Quote Reply
Re: Keyword Search & Multple word search In reply to
Sure...However, your example would NOT work since you do not have to name the submit field for LINKS's search.cgi script.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Keyword Search & Multple word search In reply to
I have made all the listed changes, uploaded the new system, and *clunk* it doesn't exactly work.

I got it working so far as it no longer gives me error messages. That's the best it does.

Going to Search.cgi, it asks me to log in. OK fine, I log in. *poof* it redirected me to db.cgi. Annoying.

So I thought I'd cheat, re: my previous message. I went to the example search page in Gossamer Threads' mage. Copied the search routine and plugged it in. No thinking, no nothing. Just snagged the default code and popped it into an HTML.

I get an unexpected error when I try to search. That's all she wrote.

I've been working on this mod for a few days now, as it seems the real boolean code is top secret. I've followed the detailed steps listed numerous times, and always do I get the same results: either the CGI is incorrectly configured, or the search returns an "unexpected error" causing the script to pee down its leg and scream like a girl.

I normally don't feel like a complete idiot, but I am compelled to ask if anyone else has followed this thread and got the search.cgi script mods to work?

Thanks...
Quote Reply
Re: Keyword Search & Multple word search In reply to
Let's clarify a few things:

1) This is NOT a mod...it is a code hack.
2) I still do not gaurantee this code hack will work.
3) As I mentioned before, this code hack will probably have to be tweaked.
4) This code hack should not be in a password protected directory or implanted into the db.cgi script. It is a stand alone script answer to the Boolean search problem.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
> >