Gossamer Forum
Home : Products : DBMan : Customization :

multiple keyword searches

Quote Reply
multiple keyword searches
I was curious as to how you would go about setting up a search for multiple keywords even if the keywords are not in the order as they were originally stored. Say it has "free home" as some of the keywords. When I do a search for home free it shows No Matching Records. Any help would be appreciated.
Quote Reply
Re: multiple keyword searches In reply to
You can set the script up to do "or" searches, if you want. I don't know how to do "and" searches.

To do "or" searches:

First -- the easy way

Enter your search terms like

home|free

and check the Reg. Expr. box in the search options section.

---------------------------------
Second -- the more complicated way

In db.cgi, sub query, add the following code after

local ($sortby);

Code:
if ($in{'keyword'} =~ / /) {
$in{'keyword'} =~ s/ /|/g;
$in{'re'} = 1;
}

Enter your keywords like

home free

Downside -- you will no longer be able to search for phrases
-----------------------------------

Third -- a little more complicated

In db.cgi, sub query, add the following code after

local ($sortby);

Code:
if ($in{'keyword'} =~ / or /) {
$in{'keyword'} =~ s/ or /|/g;
$in{'re'} = 1;
}

Enter your keywords like

home or free

This allows you to still search for phrases.


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





Quote Reply
Re: multiple keyword searches In reply to
I tried it and it still doesn't work. When I do a search it still show NO Matching Records. I did the 3rd example. I have no problem getting into the program to get something to work. I just don't know how to do it on this one.
Quote Reply
Re: multiple keyword searches In reply to
Is this a keyword search or are you searching in a particular field?


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





Quote Reply
Re: multiple keyword searches In reply to
OK, I have a form set up from the main page that performs a site search. I have a drop-down box that selects the Category to search in. There is a regular input box where the keywords are typed in. So it searches for keywords in a particular field. Here is the code: <form action="cgi-bin/dbman/db.cgi" method="GET">
<input type=hidden name="uid" value="default">
<input type=hidden name="db" value="site">
<input type=hidden name="view_records" value="1">
<center><input type="text" name="Keys" size="12">
</center><br>
<font face="verdana" size="0" color="#FFFFFF"><strong>Search within:<br>
<INPUT TYPE="radio" NAME=Category VALUE="Tutorials">Tutorials<br>
<INPUT TYPE="radio" NAME=Category VALUE="Other">General</strong></font><P>
<center><INPUT TYPE="SUBMIT" NAME="view_records" VALUE="Search"></center></FORM>



[This message has been edited by brock91 (edited August 18, 1999).]
Quote Reply
Re: multiple keyword searches In reply to
Then try substituting Keys where I had keyword in the code I gave you.


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





Quote Reply
Re: multiple keyword searches In reply to
Sorry, I know you must be getting sick of me. I tried substituting Keys for keywords and I still get no results. Now if I type them in order as they were saved it works fine, but how many poeple do you know will type things like that. Most of the pages that are stored have up to 30 different keywords. There is alot of information on all those pages so the keywords can't really be knocked down any. This makes it easy to categorize but dificult to search for.
Quote Reply
Re: multiple keyword searches In reply to
I should have had you do this in the first place.

Take out the code that I gave you.

Type in your search terms with a | between them.

If you have the search options, select "Reg. Expression." If you don't, after you get the "No Matching Records" page, go up into the Location window in your browser and enter

&re=1

in the URL there. The hit your "Enter" key to do the search again.

If you still get "No Matching Records," I don't know how to help you. The only thing I know to do is to use a regular expression.


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





Quote Reply
Re: multiple keyword searches In reply to
It works for OR searches. That is cool. It really doesn't help with more than one keyword. If you come up with a way please feel free to email me. It has got me stumped pretty bad. Is there any way to make it maybe just ignore everything but the first keyword. Basically so it doesn't pop up to that No Matching Records page.
Quote Reply
Re: multiple keyword searches In reply to
I'm really confused. You said
Quote:
It works for OR searches. That is cool. It really doesn't help with more than one
keyword.

What do you mean "more than one keyword"? I thought that meant doing an "or" search.


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





Quote Reply
Re: multiple keyword searches In reply to
brock91....One thought is that you could use another database driven program, such as LINKS2, that has "And" and "Or" Connectors/Boolean type options. When I looked at your site...it struck me that you could use something like LINKS2. Not to dissuade you from using DBMAN (it is a great product and I use both LINKS and DBMAN for various web projects); but you can customize LINKS to do exactly what you are looking for.

Smile

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: multiple keyword searches In reply to
OK. Let's say that several pages haves the keyword "cake" on them. For arguments sake we'll say three of them. Now on the first page there is also a keyword "chocolate", on the second "angel", and on the third "white".
Now there is also a bunch of other files, but these 3 are the only ones with "cake" being a keyword. What I want is to be able to search for "chocolate cake" and have it display only the page with "chocolate cake" as a keyword. Now if it's entered into the keywords when you first make the entry as "chocolate cake" it will find the page, but if you were to put in "cake chocolate" it will return No Matching Records. That is what I want to fix. Understand? Sorry for making this all so dificult.
Quote Reply
Re: multiple keyword searches In reply to
So what you want is an "and" search, not an "or" search.

I understand that the next version of DBMan will have this capability, but I have no idea when it will be released.


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





Quote Reply
Re: multiple keyword searches In reply to
JPDeni,

I love you!

That's all I wanted to say, this was exactly what I needed to get our "What's in the Fridge" search working.

Kylie
Quote Reply
Re: multiple keyword searches In reply to
I'm glad you were able to find it, Kylie. Now I understand what you wanted to do. (I read your post in the other DBMan forum, but I didn't really get the picture.)

BTW, I will answer your email. Smile



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






Quote Reply
Re: multiple keyword searches In reply to
About this reg. expression thing and the |-sign, is it possible to set the script to ignore the last |-sign so i can use checkboxes by just making the value something like value1| ?

I hope you understand...
Thanx,
Thijs
Quote Reply
Re: multiple keyword searches In reply to
I'm afraid I don't understand.

Can you give me an example of a field directly from your .db file to illustrate?


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






Quote Reply
Re: multiple keyword searches In reply to
Never mind, it can't work anyway, what i'm actually trying to do is to make a search with multiple checkboxes.

So for example:

In the demo-database i want a search-form with 5 checkboxes for the Type and 5 checkboxes for the Category-field.

Now if i search on type: Gopher and FTP
category: General

Iwant to see the records that have
- type: Gopher category: General
- type: FTP category: General

nothing else

Thijs Goos


[This message has been edited by Thijs Goos (edited May 09, 2000).]
Quote Reply
Re: multiple keyword searches In reply to
You can eliminate the last | when records are added to the database or when a search is performed.

In sub parse_form, after

Code:
if ($value eq "---") { next PAIR; }

add

Code:
unless ($value) { next PAIR; }



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