开发者

how to parse google-style search syntax

I would like to be able to enter search strings in my web application (php) similar to google's style, for example:

  1. frank
  2. frank -jones
  3. created:2010-5-1...2011-6-3 deleted:false

From this I would like a php data structure from which i can build an sql query. The first would search my contact table for "full_name like %frank%". The second would search it for "full_name like %frank% and not like %jones%", the third would search for "created between 2010-5-1 and 2011-6-3 and deleted=0"

i开发者_运维技巧 believe what i need is a context-free grammer parser. Is there a good one for PHP?

Thanks!


Would it not be better to load the table result on the first search in an array then base if off of that using AJAX?

It may not be, but google got the hosting power to do what they want, depending on your hosting and your usage of DB calls it may not result in the same way you think it will do.

Just a thought.


gee, don't everyone rush in at once...

the answer is: "hey, why don't you look at the source code for Lucene's Query Parser? Because it does exactly what you are looking for. In fact, you should just use Lucene, as it's probably going to be easier."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜