<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHPKuh.de &#187; Datenbank</title>
	<atom:link href="http://phpkuh.de/kategorie/datenbank/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpkuh.de</link>
	<description>Just a man, a computer and his PHP</description>
	<lastBuildDate>Thu, 01 May 2008 23:18:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spa&#223; mit MySQL Stopwords</title>
		<link>http://phpkuh.de/spass-mit-mysql-stopwords/</link>
		<comments>http://phpkuh.de/spass-mit-mysql-stopwords/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 22:19:18 +0000</pubDate>
		<dc:creator>Chefkoch</dc:creator>
				<category><![CDATA[Datenbank]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[stopwords]]></category>
		<category><![CDATA[umzug]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://phpkuh.de/spass-mit-mysql-stopwords/</guid>
		<description><![CDATA[Gleich noch ein Problem hinterher, das auch im Zuge des Umzugs eines Projekts von MySQL 4 auf 5 aufgetreten ist: ich wollte mit einer Volltext-Suche nach einem oder mehreren Worten in einer Liste aus Worten arbeiten. In manchen F&#228;llen enthielt die Suchwort-Liste den Begriff "help". In diesem besonderen Fall, kamen ganz ungew&#246;hnliche Ergebnisse zustande und [...]]]></description>
			<content:encoded><![CDATA[<p>Gleich noch ein Problem <a href="/mysql-fulltext-search-minimum-word-length/" title="MySQL Fulltext Minmum Char Problem" target="_blank">hinterher</a>, das auch im Zuge des Umzugs eines Projekts von MySQL 4 auf 5 aufgetreten ist: ich wollte mit einer Volltext-Suche nach einem oder mehreren Worten in einer Liste aus Worten arbeiten. In manchen F&#228;llen enthielt die Suchwort-Liste den Begriff "help". In diesem besonderen Fall, kamen ganz ungew&#246;hnliche Ergebnisse zustande und bestimmt Eintr&#228;ge wurden nicht selektiert, die aber eigentlich gefunden werden sollten. Auf dem alten MySQL4-Server funktionierte die Suche problemlos. Was war los?<span id="more-6"></span></p>
<p>Es gibt f&#252;r Volltextsuchen eine Stopwords-Liste, die in der MySQL-Installation einkompiliert ist. Diese Liste enth&#228;lt <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-stopwords.html" title="Stopwords-Liste von MySQL5" target="_blank">etliche Worte</a>, die h&#228;ufig in der Sprache vorkommen. So z.B. "an", "and", "any", "all" ... usw. und eben auch besagtes "help".</p>
<p>Um nun nicht MySQL neu kompilieren zu m&#252;ssen, kann man auch eine externe Wortliste per Konfigurationsanweisung  <a href="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#option_mysqld_ft_stopword_file" title="MySQL-Konfigurations-Anweisung ft_stopword_file" target="_blank">ft_stopword_file</a> angeben. Also schnell eine externe Wortliste besorgen (z.B. <a href="http://phpkuh.de/uploads/2007/11/common_words" target="_blank" title="Common Words als MySQL-Stopwords-Liste">hier</a>), anpassen (z.B. das "help" entfernen) und eine Zeile in die /etc/mysql/my.cnf eintragen:</p>
<p><code>ft_stopword_file = /etc/mysql/common_words</code></p>
<p>Und den MySQL-Server neustarten. Anschlie&#223;end sollten auch Volltext-Suchen nach "help" funktionieren. Also z.B. derartiges:</p>
<div class="igBar"><span id="lsql-2"><a href="#" onclick="javascript:showPlainTxt('sql-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-2">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> articles <span style="color: #993333; font-weight: bold;">WHERE</span> MATCH <span style="color:#006600; font-weight:bold;">&#40;</span>tags<span style="color:#006600; font-weight:bold;">&#41;</span> AGAINST <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'+help +health'</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">BOOLEAN</span> MODE<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>(Finde alle Eintr&#228;ge in der Tabelle "articles" bei denen im Feld tags sowohl "help" als auch "health" vorkommt)</p>
<p>Ob das Verwenden einer externen Stopwords-Datei anstatt der einkompilierten Liste sich signifikant nachteilig auf die MySQL-Perfomance auswirkt habe ich noch nicht &#252;berpr&#252;ft oder rausgesucht. Sachdienliche Hinweise dazu nehme ich gern in den Kommentaren entgegen.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpkuh.de/spass-mit-mysql-stopwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Fulltext Search Minimum Word Length</title>
		<link>http://phpkuh.de/mysql-fulltext-search-minimum-word-length/</link>
		<comments>http://phpkuh.de/mysql-fulltext-search-minimum-word-length/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 22:20:36 +0000</pubDate>
		<dc:creator>Chefkoch</dc:creator>
				<category><![CDATA[Datenbank]]></category>
		<category><![CDATA[against]]></category>
		<category><![CDATA[fulltext]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://phpkuh.de/mysql-fulltext-search-minimum-word-length/</guid>
		<description><![CDATA[Beim Switch eines Projekts von MySQL4 auf MySQL5 ist es mir vor kurzem passiert, dass die Suche nicht mehr zufriedenstellend funktionierte: Beitr&#228;ge, die eigentlich selektiert werden sollten, kamen einfach nicht mehr zu vorschein. Dort gab es also soetwas wie:
SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE);
Eine Fehlersuche von mehr als [...]]]></description>
			<content:encoded><![CDATA[<p>Beim Switch eines Projekts von MySQL4 auf MySQL5 ist es mir vor kurzem passiert, dass die Suche nicht mehr zufriedenstellend funktionierte: Beitr&#228;ge, die eigentlich selektiert werden sollten, kamen einfach nicht mehr zu vorschein. Dort gab es also soetwas wie:</p>
<p><code>SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE);</code></p>
<p><span id="more-5"></span>Eine Fehlersuche von mehr als einer halben Stunde brachte dann zutage, dass es sich um die minimale L&#228;nge der bei Fulltext-Anfragen verwendeten Suchworte handeln k&#246;nnte, wie auch in der Dokumentation <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html" title="MySQL-Dokumentation zu Fulltext-Queries" target="_blank">zu lesen</a> ist:</p>
<blockquote><p>The minimum and maximum word length full-text parameters apply.</p></blockquote>
<p>Ein Blick auf "MySQL-System-Variablen anzeigen" im phpMyAdmin zeigte auch tats&#228;chlich an, dass dort 4 f&#252;r den entsprechenden Parameter eingestellt war:</p>
<p>ft min word len   4</p>
<p>Und im Forum findet sich <a href="http://forums.mysql.com/read.php?21,69630,69734#msg-69734" title="L&#246;sung zum Problem bei zu kurzen Fulltext-Anfragen" target="_blank">die L&#246;sung</a>:</p>
<blockquote><p> SET GLOBAL ft_min_word_len=3; should do the trick. You need SUPER privilege.</p>
<p>Note: FULLTEXT indexes must be rebuilt after changing this variable. Use REPAIR TABLE tbl_name QUICK.</p></blockquote>
<p>Die &#196;nderung m&#246;chte ich aber f&#252;r den gesamten MySQL-Server verf&#252;gbar haben, und nicht nur zur Laufzeit. Also schnell als root folgendes in die /etc/mysql/my.cnf hinzugef&#252;gt:</p>
<p><code>ft_min_word_len = 3</code></p>
<p>und dann noch den MySQL-Server neu starten:</p>
<p><code>/etc/init.d/mysql restart</code></p>
<p>Nicht vergessen sollte man nat&#252;rlich auch das</p>
<p><code>REPAIR TABLE table_name QUICK;</code></p>
<p>damit der Index auch neu generiert wird. Und nun funktioniert auch die Suche wieder so wie vorher, auch bei 3-buchstabigen Suchworten...</p>
]]></content:encoded>
			<wfw:commentRss>http://phpkuh.de/mysql-fulltext-search-minimum-word-length/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
