I have been trying to find an easy way to parse a search query and convert it to an SQL query for my DB.
I have found two solutions:
Any other ideas?
SQL-ORM is a very lightweight Java library which includes the ability to construct a (dynamic) SQL query in Java as a graph of objects
IMHO, this is a far better technique for building dynamic SQL queries than the usual String concatentation method.
Disclaimer: I have made some very minor contributions to this project
What exactly do you have in mind? I've used Lucene for text-searching, but where it excels is building an index and searching that instead of hitting the database at all.
I recently set up an system where I index a table in Lucene by concatenating all the columns (separated by spaces) into one field, and popping that into Lucene, and then also adding the primary key in a separate column. Lucene does all the searching and returned a list of primary keys, which I used to pull up a populated set of results and display to the user.
Converting a search query into a SQL statement would seem to me to be a little messy.
Also, here's a great beginning tutorial explaining the basic structure of Lucene.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With