You might have noticed the new link Tag search which directs you to a new page where you are asked to enter a query.
Julian and I have implemented a simple tag query language to be able to perform more complex searches over the tags:
Here is another query simply to show you some other syntax:
The features so far are:
- Simple but powerful syntax
- Auto completion
- Highlighted error messages
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.
The table layout was predefined by the taxonomy module. The first attempt was using SQL UNION and INTERSECT set operations to implement the boolean and, or and xor. It turned out, that MySQL up to version 5 does not support INTERSECT.
So only UNION could be used for the or. I decided to implement the and by doing a join and then using the WHERE clause "t1='term1' and t2='term2'". After that it took a long while to figure out the proper SQL-Slang for MySQL.
At some places it was necessary to do something like
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.
I hope you enjoy it!