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

Discussion in 'ASP .Net' started by neilmcguigan@gmail.com, Oct 29, 2005.

  1. Guest

    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!
     
    , Oct 29, 2005
    #1
    1. Advertising

  2. wrote in news:1130625019.626696.87230
    @g44g2000cwa.googlegroups.com:

    > anyone have a reference that shows this being done?


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


    --
    Stan Kee ()
     
    Usenet Honey Pot, Oct 30, 2005
    #2
    1. Advertising

  3. Guest

    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
     
    , Oct 30, 2005
    #3
  4. 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.

    <> wrote in message
    news:...
    > 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
    >
     
    Kevin Spencer, Oct 30, 2005
    #4
  5. wrote in news:1130630988.933755.130820
    @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?)

    --
    Stan Kee ()
     
    Usenet Honey Pot, Oct 30, 2005
    #5
  6. scwebgroup

    Joined:
    Jun 26, 2011
    Messages:
    1
    I've just posted an article at http://www.blackbeltcoder.com/Articles/files/reading-and-writing-csv-files-in-c that parses a search query into a simple expression tree. My code converts the input into a SQL Server Full-Text Search query, but should be useful if you are interested in parsing search terms in a way that allows you to support and control operator precedence using parentheses.
     
    scwebgroup, Jun 26, 2011
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=

    Google search result like site search!! How?

    =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    708
    Lucas Tam
    May 6, 2005
  2. Omar
    Replies:
    0
    Views:
    375
  3. Omar
    Replies:
    2
    Views:
    479
  4. Duncan Smith
    Replies:
    3
    Views:
    441
    Duncan Smith
    Apr 25, 2007
  5. JSH
    Replies:
    0
    Views:
    402
Loading...

Share This Page