Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a parser for search queries

for example i'd need to create something like google search query parser to parse such expressions as:

flying hiking or swiming -"**walking in boots **" **author:**hamish **author:**reid

or

house in new york priced over $500000 with a swimming pool

how would i even go about start building something like it? any good resources?

c# relevant, please (if possible)

  • edit: this is something that i should somehow be able to translate to a sql query
like image 238
b0x0rz Avatar asked Nov 07 '09 17:11

b0x0rz


1 Answers

How many keywords do you have (like 'or', 'in', 'priced over', 'with a')? If you only have a couple of them I'd suggest going with simple string processing (regexes) too.

But if you have more than that you might want to look into implementing a real parser for those search expressions. Irony.net might help you with that (I found it extremely easy to use as you can express your grammar in a near bnf-form directly in code).

like image 145
andyp Avatar answered Oct 24 '22 02:10

andyp