<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>Creating better search suggestions with Sphider</title>
<link>http://www.mdj.us/</link>
<description>A simple hack to improve the search suggestion function in the Sphider search engine.</description>
<language>en</language>
<item>
<title>Test Sphider</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1536</link>
<pubDate>Sun, 27 Nov 2011 13:58:49 +0000</pubDate>
<content:encoded><![CDATA[Hi again,<br />
<br />
I've been searching and I guess the solution lies in &quot;preg_match&quot; in spiderfunc.php and &quot;$entities = array&quot; part in comonfuncs.php. But I could not do it..]]></content:encoded>
</item>
<item>
<title>Test Sphider</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1533</link>
<pubDate>Fri, 25 Nov 2011 23:23:21 +0000</pubDate>
<content:encoded><![CDATA[It sounded a good idea. I tested it. But this time, it didn't highlighted the word found and also it didn't found with capital letters :)<br />
In previous version when I typed çanakkale it asked &quot;did you mean Çanakkale&quot; and clicking on Çanakkale brought Çanakkale results not ÇANAKKALE. In this version, when I type Çanakkale it asked &quot;did you mean çanakkale&quot; which is weird because I only have Çanakkale and ÇANAKKALE in page. It finds the page but no highlighting. :))<br />
<br />
I also removed that special characters from remove accents part in commonfuncs.php file but no help.<br />
<br />
It is really interesting and drives me crazy. I could not find any solution to this. It clearly recognizes the words but we need to tell ğ=Ğ, ş=Ş or Ç=ç so that it matches all and highlights them.<br />
<br />
If you find any ideas or any solutions to this, I'll keep an eye on this page..<br />
<br />
Thank you for everything.]]></content:encoded>
</item>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1532</link>
<pubDate>Fri, 25 Nov 2011 21:47:49 +0000</pubDate>
<content:encoded><![CDATA[Ahhh, you're quite right, haha, this one got butchered, I better check my other articles. Thanks for the trouble shooting!<br />
<br />
Regarding the case-sensitive searching, I believe that Sphider itself converts all the strings to lowercase using PHP's strtolower function before storing them in the database so that the md5 hashes match... i.e. searching on &quot;GaMe&quot; would match &quot;game&quot; or &quot;GAME&quot;. It's possible that it's mucking up the latin 5 characters when it's doing that, so the md5 hashes aren't matching when searching.<br />
<br />
For a quick fix, I would try replacing all the strtolower function calls in spiderfuncs.php, searchfuncs.php, etc with the mb_strtolower function then re-indexing &amp; checking again, but that's just a wild guess at this point.]]></content:encoded>
</item>
<item>
<title>Test Sphider</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1531</link>
<pubDate>Fri, 25 Nov 2011 21:32:36 +0000</pubDate>
<content:encoded><![CDATA[Thank you again. I appreciate your help. &quot;Did you mean&quot; function is now working but one &quot;}&quot; character should be deleted.<br />
<br />
Fow the case problem.. I read the url you've supplied. But I dont want the query to be converted into lower case or upper case. What I want is :<br />
<br />
When you search a query &quot;book&quot;, it matches all word regardless of case right? (highlights book and Book and BOOK). But in case of latin 5 characters it doesn't work in the same way. It become case sensitive. Do you have any idea to tell the script to search everything case intensive?]]></content:encoded>
</item>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1530</link>
<pubDate>Fri, 25 Nov 2011 20:31:27 +0000</pubDate>
<content:encoded><![CDATA[Hi again,<br />
<br />
Sorry about that, I just took a look at the code. It seems when I moved to a new content management system recently a part of the code block to be replaced was stripped out of the original article. Try replacing the code block now listed above.<br />
<br />
For finding the lowercase, you can try using PHP's multibyte function;<br />
<a href="http://php.net/manual/en/function.mb-strtolower.php" rel="nofollow">http://php.net/manual/en/function.mb-strtolower.php</a><br />
<br />
Something like this maybe?<br />
[php]<br />
$query = mb_strtolower(str_replace('&quot;','',$query), 'iso-8859-9');<br />
[/php]]]></content:encoded>
</item>
<item>
<title>Test Sphider</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1529</link>
<pubDate>Fri, 25 Nov 2011 09:21:12 +0000</pubDate>
<content:encoded><![CDATA[Regarding my other question..<br />
<br />
My html page charsets are windows-1254. I changed my database collation to latin5_turkish_ci.<br />
I added this code to database.php:<br />
mysql_query(&quot;SET NAMES 'latin5'&quot;); <br />
mysql_query(&quot;SET CHARACTER SET latin5&quot;); <br />
mysql_query(&quot;SET COLLATION_CONNECTION = 'latin5_turkish_ci'&quot;);<br />
No problems displaying the characters. I have &quot;AĞRI&quot; in one of my page title. When I search &quot;ağrı&quot;,it only search for &quot;ağrı&quot; not &quot;AĞRI&quot; and as a result highlights &quot;ağrı&quot; only.<br />
<br />
Thanks again for your help in advance.]]></content:encoded>
</item>
<item>
<title>Test Sphider</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1528</link>
<pubDate>Fri, 25 Nov 2011 09:17:43 +0000</pubDate>
<content:encoded><![CDATA[I meant the code actually is not consisting of 4 lines in 1.3.5 version:<br />
The 4th line and the remaining part in my case is:<br />
<br />
[code]<br />
if ($distance &lt; $max_distance &amp;&amp; $distance &lt;4) {<br />
    $max_distance = $distance;<br />
    $near_word = $row[0];<br />
    }<br />
}<br />
if ($near_word != &quot;&quot; &amp;&amp; $word != $near_word) {<br />
    $near_words[$word] = $near_word;<br />
    }<br />
}<br />
[/code]<br />
<br />
When I change this whole code with the code you provided, &quot;did you mean function&quot; is not working.]]></content:encoded>
</item>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1527</link>
<pubDate>Thu, 24 Nov 2011 23:14:32 +0000</pubDate>
<content:encoded><![CDATA[Hi there, <br />
<br />
Yes, as I noted, you need to REPLACE those 4 lines with the code I provided. <br />
<br />
I'm not certain about case sensitivity with non Latin languages, I will have to investigate that &amp; get back to you.]]></content:encoded>
</item>
<item>
<title>Test Sphider</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1526</link>
<pubDate>Thu, 24 Nov 2011 22:52:33 +0000</pubDate>
<content:encoded><![CDATA[hi,<br />
did you mean replacing these whole codes with the code you provided?:<br />
starting from<br />
$near_word =&quot;&quot;;<br />
<br />
ends with<br />
<br />
$near_words[$word] = $near_word;<br />
				}<br />
<br />
			}<br />
<br />
second question:<br />
<br />
sphider does not do case intensive searches for non english characters. How can we correct this?]]></content:encoded>
</item>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/php-programming/creating-better-search-suggestions-with-sphider/#comment-1404</link>
<pubDate>Thu, 19 May 2011 18:40:41 +0000</pubDate>
<content:encoded><![CDATA[Hi Willy,<br />
<br />
Yes, do that on both instances... to make it easier, we could simply put this at the top of the function below the list of global variables, and that would cover it throughout;<br />
<br />
[code]$query=strtolower($query);[/code]<br />
<br />
but either way works :)<br />
]]></content:encoded>
</item>
</channel>
</rss>

