<?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>The Aust Gate &#187; mysql</title>
	<atom:link href="http://austgate.co.uk/tags/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://austgate.co.uk</link>
	<description>Open Knowledge and Literature</description>
	<lastBuildDate>Sun, 25 Jul 2010 15:19:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Full text search using PHP and MySQL</title>
		<link>http://austgate.co.uk/2009/12/full-text-search-using-php-and-mysql/</link>
		<comments>http://austgate.co.uk/2009/12/full-text-search-using-php-and-mysql/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 19:38:19 +0000</pubDate>
		<dc:creator>iain_emsley</dc:creator>
				<category><![CDATA[Information Retrieval]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://austgate.co.uk/?p=106</guid>
		<description><![CDATA[I&#8217;ve been thinking about full text searching for the letters project and trying to find various solutions that are open source. On the Open Shakespeare and Open Milton sites, we used the Xapian  project which is an excellent search engine. However I wanted to try and find a way of getting a search running using [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking about full text searching for the letters project and trying to find various solutions that are open source. On the <a title="The Open Shakespeare site" href="http://openshakespeare.org/" target="_blank">Open Shakespeare</a> and <a title="Open Milton site" href="http://openmilton.org/" target="_blank">Open Milton</a> sites, we used the Xapian  project which is an excellent search engine. However I wanted to try and find a way of getting a search running using PHP and MySQL which is what the site uses at the moment although I&#8217;d be happy to also use Perl. (I also wanted to impose a limit to use technologies that I currently use at my current job.)</p>
<p>I started with reading an <a title="Zend article on full text searching with PHP and MySQL" href="http://devzone.zend.com/article/1304" target="_blank">article  on the Zend</a> site that offers an overview of setting up a table to run with a <a title="MySQL manual on full text searching" href="http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html" target="_blank">Full-Text</a> index. As the article mentions, you have to ensure that the column which is being searched is either VARCHAR or TEXT as MySQL. If it is not in either form, then just alter the column using</p>
<blockquote><p>ALTER TABLE &lt;tablename&gt; MODIFY &lt;column&gt; TEXT</p></blockquote>
<p>(or VARCHAR but TEXT is probably preferable). What the Zend article does not mention is that the table type needs to by MyISAM rather than use InnoDB (which means that transactions won&#8217;t work on the table). Having made the alteration, I ran the query:</p>
<blockquote>
<div>SELECT * , MATCH (&lt;table&gt;) AGAINST (&#8216;&lt;search term&gt;&#8217;) AS score FROM &lt;table&gt; WHERE MATCH (&lt;table&gt;) AGAINST (&#8216;&lt;search term&gt;&#8217;)</div>
</blockquote>
<p>The table returns all the columns with a score against the term.</p>
<p>The SQL code just needs calling as you would any other form of database code. I&#8217;m still playing with this but I&#8217;ve been ordering the table by the score descending (ORDER BY score DESC) so that the most relevant results are posted for the user.</p>
<p>I do think that I need to do some pre-processing on my own results set to highlight relevance and to extract further semantic meanings for results. For example the publisher &#8216;Chapman and Hall&#8217; that I could run on the Dickens letters (<a title="Dickens letters search example" href="http://austgate.co.uk/dickens/search.php?term=Chapman&amp;submit=Submit+Query" target="_blank">http://austgate.co.uk/dickens/search.php?term=Chapman&amp;submit=Submit+Query</a>) could equally pull up other businesses or people. I still need to write a parser that can make some sort of judgement even if it is a guess.</p>
<p>I&#8217;m sure as I carry on developing the engine and bringing everything together for the project, I&#8217;ll have further thoughts on the creation of an engine and creating a more advanced version. This does at least give me a start using current tools (though it is perhaps not as good as Xapian but sometimes you have to at least learn some of the basics).</p>
]]></content:encoded>
			<wfw:commentRss>http://austgate.co.uk/2009/12/full-text-search-using-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
