Skip to main content.
home | support | download

Back to List Archive

Re: escaping quotes and paren's in swish query

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Wed Sep 15 2004 - 13:34:19 GMT
On Tue, Sep 14, 2004 at 04:21:07AM -0700, Tac wrote:
> If I want to search for the phrase with a double-quote in it (e.g. 17" flat
> screen), how do I escape the string in swish-e?  I'm getting the error:
> Syntax error in query (missing end quote or unbalanced parenthesis?)

Well, I started to look at the code this morning and saw this comment:

** 2001-12-11  moseley, updated to deal with swish operators inside of phrases
**                      Still broken with regard to double-quotes inside of phrases
**                      Very unlikely someone would want to search for a single double quote
**                      within a phrase.  It currently works if the double-quotes doesn't have
**                      white space around.  Really should tag the words as being operators, or
**                      or "swish words", or let the backslash stay in the query until searching.

Which sounds like it should work -- and it does:

    $ swish-e -w ' "Phrase with quotes 17\""' -H9 | grep Parsed
    # Parsed Words: " phrase with quotes 17" "

Like the comment says, it doesn't work if there's white space next to
(seems like only before) the quotes:

    $ swish-e -w ' "Phrase with quotes 17 \""' -H9 -E | grep Parsed
    err: Syntax error in query (missing end quote or unbalanced parenthesis?)
    .
    # Parsed Words: 

    $ swish-e -w ' "Phrase with quotes 17\" "' -H9 -E | grep Parsed
    # Parsed Words: " phrase with quotes 17" " 

    $ swish-e -w 'not in a phrase 17\"' -H9 -E | grep Parsed
    # Parsed Words: not in a phrase 17"

And searching works:

    $ swish-e -w '"17\" flat screen" ' -H0
    1000 1.html "New 17" flat screen!" 129

And since the double quotes is part of wordcharacters:

    $ swish-e -w '"17 flat screen"'
    # SWISH format: 2.5.1
    # Search words: "17 flat screen"
    # Removed stopwords: 
    err: no results
    .

So you probably wouldn't want the quotes indexed (in WordCharacters):

    $ swish-e -i 1.html -v0

    $ swish-e -w '"17\" flat screen"'
    # SWISH format: 2.5.1
    # Search words: "17\" flat screen"
    # Removed stopwords: 
    # Number of hits: 1
    # Search time: 0.020 seconds
    # Run time: 0.039 seconds
    1000 1.html "New 17" flat screen!" 129
    .


-- 
Bill Moseley
moseley@hank.org

Unsubscribe from or help with the swish-e list: 
   http://swish-e.org/Discussion/

Help with Swish-e:
   http://swish-e.org/current/docs
   swish-e@sunsite.berkeley.edu
Received on Wed Sep 15 06:42:09 2004