<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.eiffelroom.org" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>eiffelroom - Tag search - Comments</title>
 <link>http://www.eiffelroom.org/blog/mtn/tag_search</link>
 <description>Comments for &quot;Tag search&quot;</description>
 <language>en</language>
<item>
 <title>Tag search</title>
 <link>http://www.eiffelroom.org/blog/mtn/tag_search</link>
 <description>&lt;p&gt;You might have noticed the new link &lt;a href=&quot;/query&quot;&gt;Tag search&lt;/a&gt; which directs you to a new page where you are asked to enter a query.&lt;/p&gt;

&lt;p&gt;Julian and I have implemented a simple tag query language to be able to perform more complex searches over the tags: &lt;pre class=&quot;geshifilter&quot;&gt;tcp -udp&lt;/pre&gt; This query will return all content which has the tag &amp;quot;tcp&amp;quot; but is not tagged with &amp;quot;udp&amp;quot; yielding in content only related to the TCP.&lt;/p&gt;

&lt;p&gt;Here is another query simply to show you some other syntax: &lt;pre class=&quot;geshifilter&quot;&gt;tcp xor not tcp&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;The features so far are:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt; Simple but powerful syntax&lt;/li&gt;
    &lt;li&gt; Auto completion&lt;/li&gt;
    &lt;li&gt; Highlighted error messages&lt;/li&gt;
&lt;/ul&gt;


&lt;h2 id=&quot;toc0&quot;&gt;Implementation&lt;/h2&gt;
&lt;p&gt;After little success with &lt;a href=&quot;http://netevil.org/node.php?nid=941&amp;amp;SC=1|PHP&quot;&gt;backends&lt;/a&gt; for lemon and JLex (the generated code did not work) we used the generators (&lt;a href=&quot;http://pear.chiaraquartet.net/PHP_LexerGenerator/PHP_LexerGenerator/_LexerGenerator---Lexer.php.html&quot;&gt;lexer&lt;/a&gt;, &lt;a href=&quot;http://pear.chiaraquartet.net/PHP_ParserGenerator/li_PHP_ParserGenerator.html&quot;&gt;parser&lt;/a&gt;) from the PEAR library.&lt;/p&gt;

&lt;p&gt;The next hurdle was the code generation for MySQL. First we translate the strings into integer IDs to get faster query execution. This was the easy part.&lt;/p&gt;

&lt;p&gt;The table layout was predefined by the taxonomy module. The first attempt was using SQL  &lt;em&gt;UNION&lt;/em&gt; and &lt;em&gt;INTERSECT&lt;/em&gt; set operations to implement the boolean &lt;em&gt;and&lt;/em&gt;, &lt;em&gt;or&lt;/em&gt; and &lt;em&gt;xor&lt;/em&gt;. It turned out, that MySQL up to version 5 does not support &lt;em&gt;INTERSECT&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;So only &lt;em&gt;UNION&lt;/em&gt; could be used for the &lt;em&gt;or&lt;/em&gt;. I decided to implement the &lt;em&gt;and&lt;/em&gt; by doing a join and then using the &lt;em&gt;WHERE&lt;/em&gt;  clause &amp;quot;t1=&#039;term1&#039; and t2=&#039;term2&#039;&amp;quot;. After that it took a long while to figure out the proper SQL-Slang for MySQL.&lt;/p&gt;

&lt;p&gt;At some places it was necessary to do something like &lt;pre class=&quot;geshifilter&quot;&gt;SELECT * FROM (SELECT ... real query ...) AS a_name&lt;/pre&gt; in order to have no unnamed sub-queries. The error message was really bad but Google (once again) knew the answer :-)&lt;/p&gt;

&lt;p&gt;After that we decided to add some sugar. This includes highlighting the parts of an erroneous query and, even more important, a powerful auto-completion using AJAX functionality built into Drupal. Julian said its implementation worked like a charm.&lt;/p&gt;

&lt;p&gt;I hope you enjoy it!&lt;/p&gt;

</description>
 <comments>http://www.eiffelroom.org/blog/mtn/tag_search#comments</comments>
 <category domain="http://www.eiffelroom.org/tag/auto_completion">auto completion</category>
 <category domain="http://www.eiffelroom.org/tag/eiffelroom">eiffelroom</category>
 <category domain="http://www.eiffelroom.org/tag/mysql">mysql</category>
 <category domain="http://www.eiffelroom.org/tag/parser">parser</category>
 <category domain="http://www.eiffelroom.org/tag/parsing">parsing</category>
 <category domain="http://www.eiffelroom.org/tag/query">query</category>
 <category domain="http://www.eiffelroom.org/tag/search">search</category>
 <category domain="http://www.eiffelroom.org/tag/tag">tag</category>
 <category domain="http://www.eiffelroom.org/taxonomy/term/156">饮料酒</category>
 <pubDate>Thu, 08 Mar 2007 12:06:43 -0800</pubDate>
 <dc:creator>mtn</dc:creator>
 <guid isPermaLink="false">120 at http://www.eiffelroom.org</guid>
</item>
</channel>
</rss>
