Welcome! Log In Create A New Profile

Advanced

Sphider cant find texts with the character "/"

Posted by elgamaser 
Sphider cant find texts with the character "/"
August 07, 2011 08:41AM
For example, I have a document which includes "number 150/007".

If I look for "150/007" it does not match results. If I look for 150 007 it finds all documents with "150" and all documents with "007", including the document with "150/007", and it is shown with the text "150/007", but it does not recognize "150/007".

Anyone has a idea about how fix it ?

Thanks.
Tec
Re: Sphider cant find texts with the character "/"
August 07, 2011 06:23PM
Doesn't work with original Sphider, as during index procedure, all special characters likes slashes are replaced with a blank character. So 1500/007 will become 2 separate keywords in database:
1500
007
Afterwards you are unable to search for 1500/007

In order to sove it, open the script
.../admin/spiderfuncs.php
and search for
$file = preg_replace("/[\*\^\+\?\\\.\[\]\^\$\|\{\)\(\}~!\"\/@#£$%&=`´;><:,]+/", " ", $file);
Delete that row and replace it with
    preg_match_all("/[\d\w'-_]+[\/][\d\w\.,'-_\?\!]+/si", $file, $regs, PREG_SET_ORDER);
    foreach ($regs as $value) {
        $all .= " ".$value[0]."";
    }        
    $file  = preg_replace("/[\*\^\+\?\\\.\[\]\^\$\|\{\)\(\}~!\"\/@#£$%&=`´;><:,]+/", " ", $file);
    $file .= $all;

Afterwards clear your complete database (without the sites table) and re-index all.

In order to highlight the results containing a slash, you additionally will have to do the following modification.

Open the script
…/include/searchfuncs.php
and search for
			foreach($words['hilight'] as $change) {
				while (preg_match("/[^\>](".$change."winking smiley[^\<]/i", " ".$title." ", $regs)) {
					$title = preg_replace("/".$regs[1]."/i", "<b>".$regs[1]."</b>", $title);
				}

				while (preg_match("/[^\>](".$change."winking smiley[^\<]/i", " ".$fulltxt." ", $regs)) {
					$fulltxt = preg_replace("/".$regs[1]."/i", "<b>".$regs[1]."</b>", $fulltxt);
				}
				$url2 = $url;
				while (preg_match("/[^\>](".$change."winking smiley[^\<]/i", $url2, $regs)) {
					$url2 = preg_replace("/".$regs[1]."/i", "<b>".$regs[1]."</b>", $url2);
				}
			}
Delete the above and replace it with
			foreach($words['hilight'] as $change) {         
				while (preg_match("~[^\>](".$change."winking smiley[^\<]~i", " ".$title." ", $regs)) {
					$title = preg_replace("~".$regs[1]."~i", "<b>".$regs[1]."</b>", $title);
				}
				while (preg_match("~[^\>](".$change."winking smiley[^\<]~i", " ".$fulltxt." ", $regs)) {                
					$fulltxt = preg_replace("~".$regs[1]."~i", "<b>".$regs[1]."</b>", $fulltxt);
				}
				$url2 = $url;
				while (preg_match("~[^\>](".$change."winking smiley[^\<]~i", $url2, $regs)) {               
					$url2 = preg_replace("~".$regs[1]."~i", "<b>".$regs[1]."</b>", $url2);
				}
			}

By the way, a similar issue you will meet, whenever you try to index (and search for) prices like Euro 123.45 with original Sphider.

Final note:
I do not have enough time to remove all the sennsless smilies from my code.
Dear Ando: remove this nonsense from your forum! Especially inside of [ code ] tags.

Tec



Edited 1 time(s). Last edit at 08/07/2011 06:26PM by Tec.
Re: Sphider cant find texts with the character "/"
November 16, 2011 09:34AM
Hi Tec,

How would this change if you want to index the # character.. ? As in I currently cannot index the words C#.net or C++ ?

Please help.
Thanks,
Re: Sphider cant find texts with the character "/"
November 16, 2011 03:19PM
open the script
.../admin/spiderfuncs.php
and search for
$file = preg_replace("/[\*\^\+\?\\\.\[\]\^\$\|\{\)\(\}~!\"\/@#£$%&=`´;><:,]+/", " ", $file);
Delete the above and replace it with
$file = preg_replace("/[\*\^\?\\\.\[\]\^\$\|\{\)\(\}~!\"\/@£$%&=`´;><:,]+/", " ", $file);
Afterwards clear your complete database (without the sites table) and re-index all.

This should allow for # and + to be indexed, as far as I can see.
Re: Sphider cant find texts with the character "/"
March 28, 2012 10:41PM
Thanks for the info.
Sorry, only registered users may post in this forum.

Click here to login