PDA

View Full Version : partial/wildcard word searching


rwillmer
08-25-2005, 08:02 AM
I'd like to be able to retrieve all words matching the text I provide e.g. strdup should match pstrdup, apr_pstrdup, etc.

Is this possible with the existing code? or do I need to start hacking the SQL statements?

Rachel

Charter
08-26-2005, 08:52 PM
Try editing search_function.php like so:

$like_start = array( "start" => "%", // is empty
"any" => "%", // was a percent
"exact" => "%" // is empty
);

rwillmer
08-27-2005, 03:10 AM
Thanks for that. That seems to get the right search results.

Now, next question, the text tag is showing highlighted results in the search results for those pages where it found an exact match, but not where it found a partial match. For those, I just get the first few lines of the page displayed.

Is there a similar change I need to make for the partial matches to be highlighted too?

Rachel

Charter
08-27-2005, 09:28 AM
In search_function.php find:

switch($option) {
case 'any':
$reg_strings = "($stop_regs{1}|^)($reg_strings)()";
break;
case 'exact':
$reg_strings = "($stop_regs{1}|^)($reg_strings)($stop_regs{1}|\$)";
break;
default:
$reg_strings = "($stop_regs{1}|^)($reg_strings)()";
}

And replace with:

switch($option) {
case 'any':
$reg_strings = "()($reg_strings)()";
break;
case 'exact':
$reg_strings = "($stop_regs{1}|^)($reg_strings)($stop_regs{1}|\$)";
break;
default:
$reg_strings = "()($reg_strings)()";
}

rwillmer
08-27-2005, 09:36 AM
perfect!

thanks for the quick reply...

Rachel