AND search patch?
|
dmedia
Joined: 2005-08-18
Posts: 7 |
Posted: Wed, 2005-09-28 23:12
|
|
Hi, I'm trying to install this patch but it doesn't seem to work... https://sourceforge.net/tracker/index.php?func=detail&aid=1243397&group_id=7130&atid=357130 I edit ../modules/core/classes/GalleryCoreSearch.class I remove this part:
if (isset($options[$key])) {
$whereList[] = "$column LIKE ?";
$whereData[] = '%' . $criteria . '%';
$selectMap[$column] = $columnNumber++;;
$selectList[] = $column;
}
And replace it with this:
if (isset($options[$key])) {
//==========================================================================
// mod to use each word in textbox for a client. 11/24/2004
// 2.0-alpha-3 version
// i.e. dough boy and boy dough should both retrieve the same data.
// also, each word you type is searched for (sql LIKE)
//==========================================================================
// tweak #1 - changed to keywords like this or that or desc like this or that
$criteria_array = explode(" ", $criteria);
$total_items = count($criteria_array);
$loop_index = 0;
$countWhere = "("; // to group for AND start
while ($loop_index < $total_items) {
$criteria_item = trim($criteria_array[$loop_index]);
if (strlen($criteria_item) > 0) {
$countWhere .= "$column LIKE ?"; // make each question mark to inject data later
$whereData[] = '%' . $criteria_item . '%'; // for each question mark
if ($loop_index + 1 < $total_items) { // more words so AND needed
$countWhere .= " AND ";
}
}
$loop_index++;
} // end loop
$selectMap[$column] = $columnNumber++;;
$selectList[] = $column;
$countWhere .= ") "; // to group
$whereList[] = $countWhere;
} // end isset
Is there something else that I need to do? Thanks. |
|

Posts: 565
I've been looking for a Boolean search module. The stuff you quoted above seems to be the best workaround I've seen;~) Yes, it works. Perhaps you inappropriately overwrote the second closing "}"?
A search for "carpet heather" successfully displays a picture whose IPTC keywords include "heather; carpet;" though without the nice highlighting functionality.
A search for "heather carpet" displays and highlights OK but there again that's the out-of-the-box functionality.
----best wishes, Robert
Posts: 7
Hmmm... I fiddled with it some more and you're right, it does work. But not in the way that I expected. It does proper searching on the keywords field but not the comments field. If I have "red blue white" in the comments, a search for "red white" won't return the correct result but if I have "red blue white" in the keyword field, a search for "red white" will return the correct result.
Weird. Thanks for verifying that it works and making me take a second look.
Posts: 565
I have never had comments active, probably never will.
Posts: 40
Hi,
I tried to apply this useful patch but I get an error message when I try to search something in my gallery "unexpected T-STRING line 101". What have I done wrong??? Did you had anything else in the code? Could you please post the entire /modules/core/classes/GalleryCoreSearch.class you modified ?
Thank you very much for your help
Gallery version = 2.0.2 core 1.0.0.2
PHP version = 4.3.10-16 apache2handler
Webserver = Apache/2.0.54 (Debian GNU/Linux) FrontPage/5.0.2.2635 mod_python/3.1.3 Python/2.3.5 PHP/4.3.10-16 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_perl/1.999.21 Perl/v5.8.4
Database = mysql 4.0.24_Debian-10sarge1-log
Toolkits = ArchiveUpload, Exif, Gd
Operating system = Linux webnux.webcastor.fr 2.6.14-cks3 #3 Fri Nov 4 15:12:34 CET 2005 i686
Browser = Mozilla/5.0 (Macintosh; U; PPC Mac OS X; fr-fr) AppleWebKit/312.5.2 (KHTML, like Gecko) Safari/312.3.3
Posts: 94
I am using the following code for MySQL. It does the same thing as the above. For some reason there is no cross database fields searching being done.
For me I don't need to search across all of the g2_Item fields at the same time.
if (isset($options[$key])) {
$criteria = str_replace(" ", " +", $criteria);
$whereList[] = "MATCH($column) AGAINST ( '+' '$criteria' IN BOOLEAN MODE)";
$selectMap[$column] = $columnNumber++;;
$selectList[] = $column;
}