I think I might have a solution to those who are having problems with the Boolean MOD and the ability to search for "AND" across fields.
As I understand it, the MOD only allows people to find things like "cats AND dogs" if "cats / dogs" appears in the same field. It would not find something like Field1=Cat and Field2=Dog because it doesn't search across fields (please let me know if this has been fixed).
Anyway, since I have a very real need for a search engine that can go across fields with an AND (I don't really care about OR or anything else), I've put together a rather simple modification (I think).
I should note here one important thing--I have never programmed in PERL before. I'm not a script genius or anything. I just bought the Perl Camel book last night and went through the db.cgi script line by line looking up everything I didn't understand (kind of like reading a foreign newspaper with a dictionary--very slow).
Anyway, the suggestions offered in the BOOLEAN thread were helpful, that of smushing all fields into one line and then searching that line for the data. But in reading through the code, I found that the dbman program split the LINE into several different VALUES and then searched the VALUES against the keyword input. I just decided to skip that step.
Here's what the db.cgi file says "out of the box"
# Now we go through the database and do the actual searching.
# First figure out which records we want:
$first = ($maxhits * ($nh - 1));
$last = $first + $maxhits - 1;
open (DB, "<$db_file_name") or &cgierr("error in search. unable to open
database: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
$line = $_; chomp ($line); # Remove trailing new line.
@values = &split_decode($line);
Now, what I did was change the last line so that it doesn't access the subroutine:
@values = ($line);
If you load that up and do a search, it will find the records you want, across all fields, BUT it will print out the records with all the data in one field (not very attractive). Thus I had to find a place to split the data again before printing. What I did is added it at at this point:
# Did we find a match? We only add the hit to the @hits array if we need it. We can
# skip it if we are not sorting and it's not in our first < > last range.
if ($key_match || (!($in{'keyword'}) && !($in{'ma'}))) {{@values = &split_decode($line);
}
I added {@values = &split_decode($line);
} into that line and that handles the spliting up of the values prior to the printout.
I think this works for AND searches (which is what I needed). I don't know how this will affect other searches (I think it might really mess them up) but you could just run two copies of dbman (dbman1 and dbman2--one for keyword boolean searches and another for searches within fields).
Like I said, I've never done stuff like this before, so I'm more than happy to hear any suggestions or comments. I just wanted to make this work.
Andrew
As I understand it, the MOD only allows people to find things like "cats AND dogs" if "cats / dogs" appears in the same field. It would not find something like Field1=Cat and Field2=Dog because it doesn't search across fields (please let me know if this has been fixed).
Anyway, since I have a very real need for a search engine that can go across fields with an AND (I don't really care about OR or anything else), I've put together a rather simple modification (I think).
I should note here one important thing--I have never programmed in PERL before. I'm not a script genius or anything. I just bought the Perl Camel book last night and went through the db.cgi script line by line looking up everything I didn't understand (kind of like reading a foreign newspaper with a dictionary--very slow).
Anyway, the suggestions offered in the BOOLEAN thread were helpful, that of smushing all fields into one line and then searching that line for the data. But in reading through the code, I found that the dbman program split the LINE into several different VALUES and then searched the VALUES against the keyword input. I just decided to skip that step.
Here's what the db.cgi file says "out of the box"
# Now we go through the database and do the actual searching.
# First figure out which records we want:
$first = ($maxhits * ($nh - 1));
$last = $first + $maxhits - 1;
open (DB, "<$db_file_name") or &cgierr("error in search. unable to open
database: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
$line = $_; chomp ($line); # Remove trailing new line.
@values = &split_decode($line);
Now, what I did was change the last line so that it doesn't access the subroutine:
@values = ($line);
If you load that up and do a search, it will find the records you want, across all fields, BUT it will print out the records with all the data in one field (not very attractive). Thus I had to find a place to split the data again before printing. What I did is added it at at this point:
# Did we find a match? We only add the hit to the @hits array if we need it. We can
# skip it if we are not sorting and it's not in our first < > last range.
if ($key_match || (!($in{'keyword'}) && !($in{'ma'}))) {{@values = &split_decode($line);
}
I added {@values = &split_decode($line);
} into that line and that handles the spliting up of the values prior to the printout.
I think this works for AND searches (which is what I needed). I don't know how this will affect other searches (I think it might really mess them up) but you could just run two copies of dbman (dbman1 and dbman2--one for keyword boolean searches and another for searches within fields).
Like I said, I've never done stuff like this before, so I'm more than happy to hear any suggestions or comments. I just wanted to make this work.
Andrew