Parsing search questions in Java

I have actually been searching for a very easy means to parse a search question and also transform it to an SQL question for my DB.

I have actually located 2 remedies :

  1. Lucene : Powerful Java - based internet search engine, has a question parser yet it isn't really configurable and also I can locate a means to conveniently hack/adapt it to create SQL questions.
  2. ANTLR : An expert message lexer - parser. Made use of for constructing anything from compilers to skies scrapes. ANTLR is very configurable yet every person touching the code from currently on will need to find out a new language ...

Any various other suggestions?

2019-12-02 03:06:55
Source Share
Answers: 3

Depends a whole lot on the sort of questions you've reached parse and also rather on the framework of the information in your database. I'm mosting likely to think that you are not attempting to do complete message search in a DB (i.e. an internet search engine throughout your whole DB) because, as the majority of Information Retrieval individuals will certainly inform you, the efficiency for that is dreadful. Upside down indexes are most absolutely the most effective means of doing that.

Inform us a little bit extra concerning the real trouble : what are the customers mosting likely to input, what are they anticipating as result, and also what is the information version like. Design a search remedy without those items of details, and also you'll get a much from optimum outcome.

2019-12-03 04:48:44

What specifically do you desire? I've made use of Lucene for message - looking, yet where it succeeds is constructing an index and also looking that rather of striking the database in all.

I lately set up an system where I index a table in Lucene by concatenating all the columns (divided by rooms) right into one area, and also standing out that right into Lucene, and afterwards additionally including the main type in a different column. Lucene does all the looking and also returned a checklist of key keys, which I made use of to bring up a booming set of outcomes and also display to the customer.

Transforming a search question right into a SQL declaration would certainly appear to me to be a little unpleasant.

Additionally, below is a great beginning tutorial explaining the basic structure of Lucene.

2019-12-03 04:48:28

You are proper to think that I am not seeking complete message search. The details looks something similar to this schema for publication details : Name : string, author :string, num_pages int, publish_date :day ...

The search questions are of the type :

  1. Harry Potter (search any kind of publications whos name has both Harry and also Potter)
  2. author :Nature * web pages > 100 (publications from an author beginning with Nature with greater than 100 publications)
  3. ("New years" or Christmas) and also existing (you understand ...)
  4. physics and also release > 1/ 1/2008 (new physics publications)
2019-12-03 04:47:53