google like search syntax parsing (also posted in sql programming group)

N

neilmcguigan

this is more of a text parsing/regex kind of question, but i figured
i'd start here. please let me know if this should go somewhere else.

I'd like to implement google-like search syntax, a la
http://www.google.ca/help/refinesearch.html

so a text query like this:

("google search" "regular expressions") OR (syntax text)
aSpecificField:somevalue

[some intermediate object that holds the expressions]

and turns into an sql query like this:

([aSpecificField] LIKE '%somevalue%') AND
(([field1] LIKE '%google search%' AND [field1] LIKE '%regular
expression%') OR ([field1] LIKE '%syntax%' AND [field1] LIKE '%text%'))
OR (([field2...repeat for all fields

basically i am having trouble figuring out how to parse the text query
to keep track of brackets and double-quoted expressions. am more
interested in parsing the text than turning it into SQL.

anyone have a reference that shows this being done?

thanks in advance!
 
U

Usenet Honey Pot

(e-mail address removed) wrote in @g44g2000cwa.googlegroups.com:
anyone have a reference that shows this being done?

Have you taken a look at SQL Server Full Text Search?
 
N

neilmcguigan

hi stan

thanks for your reply. i'm looking more for info on parsing strings to
keep track of quoted and parenthesized values.

thanks

neil
 
K

Kevin Spencer

Well, your original example had the phrase "Regular Expressions" in it, and
it sounds like you're on the right track there.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.
 
U

Usenet Honey Pot

(e-mail address removed) wrote in @g14g2000cwa.googlegroups.com:
thanks for your reply. i'm looking more for info on parsing strings to
keep track of quoted and parenthesized values.

If you're going to manual parse - regular expressions is the way to go.

So basically you'll need to perfect your regular expression (Maybe use Sub-
Group matching?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top