Gossamer Forum
Home : Products : DBMan : Installation :

croos field multi-word searching

Quote Reply
croos field multi-word searching
Hi,
Is this there a 'cross-field multi-word searching' solution for dbman?
The script under http://216.169.107.32/scripts/forum/resources/Forum5/HTML/000194.html seems to be a single-field solution. Does that script of Kenneth work?
Thanks again.
Quote Reply
Re: croos field multi-word searching In reply to
Any idea anybody?
Quote Reply
Re: croos field multi-word searching In reply to
I don't know about Kenneth's mod. I haven't tried it. Have you? You might see if it would work.

I did do something myself that might work on a keyword search, although I've only tried it with a single field search.

In db.cgi, sub query, just after

Code:
# Now let's build up all the regexpressions we will use. This saves the program
# from having to recompile the same regular expression every time.
foreach $field (@search_fields) {

I added

Code:
if ($in{$db_cols[$field]} =~ / or /i) {
$in{'re'} = 1;
$in{$db_cols[$field]} =~ s/ or /|/i;
}

This allows a search for "this or that."

I'm sure I'm missing something here, and I hope anyone who sees a problem with it will let me know. Smile


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





Quote Reply
Re: croos field multi-word searching In reply to
Hey! Thanks It works when I use "word1 or word2". Both results are shown bold. Great.
But: Is there a way to just use -space- instead of "or".
Because "word1 word2" results an error like:
CGI ERROR
==========================================
Error Message : fatal error: Undefined subroutine &main:: called at ../cgi-bin/db.cgi line 380, chunk 1.

Script Location : ..../cgi-bin/db.cgi
Perl Version : 5.00404
Setup File : db.cfg
User ID : default

I will try Kennethīs Code too and let you know if it works.



Quote Reply
Re: croos field multi-word searching In reply to
I don't know of a way to use a space instead of an "or." I'm surprised that it gave you an error, though. It should look for the phrase.

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





Quote Reply
Re: croos field multi-word searching In reply to
Anything else but a search like "words1 or word2" causes an error. So searching for a "word1" shows an error.
Does it work in your script?
PG
Quote Reply
Re: croos field multi-word searching In reply to
Yep. Works fine. I'm not using it as a keyword search, but I don't see why that would make any difference.

[I deleted the reference to my client's database. I hope folks understand that I have to be careful about these things.]

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







[This message has been edited by JPDeni (edited March 24, 1999).]
Quote Reply
Re: croos field multi-word searching In reply to
It works on your site. Hmm.
Maybe this shows the problem?

# Normal searches.
$key_match = 0;
foreach $field (@search_fields) {
$_ = $values[$field]; # Reg function works on $_.
$in{'ma'} ?
($key_match = ($key_match or &{$regexp_func[$field]})) :
(&{$regexp_func[$field]} or next LINE) # ThIS is the ERROR line for the 1word search

Thanks.

[This message has been edited by pg (edited March 24, 1999).]

[This message has been edited by pg (edited March 24, 1999).]
Quote Reply
Re: croos field multi-word searching In reply to
It could be a conflict with the 'ma' option. I'm starting to get into things I'm really not sure about, though.

I'll play with it for a while and see if I can come up with a solution.

Any luck with Kenneth's code?


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





Quote Reply
Re: croos field multi-word searching In reply to
Thanks.
No luck yet with Kennethīs code. But Alex should know, because he discussed it with Kenneth. Maybe he will read this and add a comment.
PG
Quote Reply
Re: croos field multi-word searching In reply to
Anybody any idea about this?
PG
Quote Reply
Re: croos field multi-word searching In reply to
Okay. I just did a little experiment on my site. I did a keyword search with a regular expression -- &keyword=this|that&re=on

I got back exactly what I would expect. If you want to check it out, you can go to

http://www.drizzle.com/~hall/cgi-bin/dbman/db.cgi?db=child&uid=default&keyword=Hall|Hoyt&re=on&view_records=1

I don't have the mod I made to allow the word "or" between the search terms connected with this database, so I couldn't check it out with that. But the regular expression works, without any alteration of the db.cgi script at all. -- For "or" searches. Not for "and" searches.

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





Quote Reply
Re: croos field multi-word searching In reply to
Hey thanks, this works:
keyword=word1|word2&re=on
So the script allows it. So the and expression might also somehow work.
So thereīs only missing a change to the db.cgi to do this query by putting 2 words into the "view_records"-Box?
I donīt know much about perl, so I canīt do it. Alex should know.
If you got the solution, please let me know.
PG


Quote Reply
Re: croos field multi-word searching In reply to
Hi,
I finally got the regex working. Also with view_records,
"OR" goes cross field.
"AND" show only records with both words in one field.

Is there any solution?
Thanks.PG