Keyword to SQL search
Posted
by jdelator
on Stack Overflow
See other posts from Stack Overflow
or by jdelator
Published on 2010-03-19T00:15:49Z
Indexed on
2010/03/19
0:21 UTC
Read the original article
Hit count: 469
Use Case
When a user goes to my website, they will be confronted with a search box much like SO. They can search for results using plan text. ".net questions", "closed questions", ".net and java", etc.. The search will function a bit different that SO, in that it will try to as much as possible of the schema of the database rather than a straight fulltext search. So ".net questions" will only search for .net questions as opposed to .net answers (probably not applicable to SO case, just an example here), "closed questions" will return questions that are closed, ".net and java" questions will return questions that relate to .net and java and nothing else.
Problem
I'm not too familiar with the words but I basically want to do a keyword to SQL driven search. I know the schema of the database and I also can datamine the database. I want to know any current approaches there that existing out already before I try to implement this. I guess this question is for what is a good design for the stated problem.
Proposed
My proposed solution so far looks something like this
- Clean the input. Just remove any special characters
- Parse the input into chunks of data. Break an input of "c# java" into c# and java Also handle the special cases like "'c# java' questions" into 'c# java' and "questions".
- Build a tree out of the input
- Bind the data into metadata. So convert stuff like closed questions and relate it to the isclosed column of a table.
- Convert the tree into a sql query.
Thoughts/suggestions/links?
© Stack Overflow or respective owner