FAQ
Hi all,

I am using a Standard analyzer on both my search field and my query.
I use a SpanNearQuery to search on the search field.
One of the query terms has special characters like ( - round open bracket
and ) - round close bracket : How does Lucene handle this?
Also, the search field has ( and ) : How does Lucene handle this? Is it
treated as white space and ignored?

Is it possible to search for special characters ? ie if my query has ) then
it should search for it and only if my search field has ) , it should give
me a hit.

Regards,
Radha

Search Discussions

  • Erick Erickson at Jun 24, 2009 at 6:11 pm
    First, I highly, highly recommend you get a copy of Luke to examineyour
    index. It'll also help you understand the role of Analyzers.

    Your first problem is that StandardAnalyzer probably removes
    the open and close parens. See:
    http://lucene.apache.org/java/2_4_1/api/index.html
    so you can't search on them *even if* you escape the
    terms in your query parsing correctly, see:
    http://lucene.apache.org/java/2_3_2/queryparsersyntax.html#Escaping Special
    Characters

    You want to understand the implications of whatever
    analyzer you choose, or progress will be...er...difficult <G>.

    Luke will allow you to try different Analyzers and see the results of
    parsing
    queries, which will be a fine place to start...

    Best
    Erick
    On Wed, Jun 24, 2009 at 1:30 PM, Radha Sreedharan wrote:

    Hi all,

    I am using a Standard analyzer on both my search field and my query.
    I use a SpanNearQuery to search on the search field.
    One of the query terms has special characters like ( - round open bracket
    and ) - round close bracket : How does Lucene handle this?
    Also, the search field has ( and ) : How does Lucene handle this? Is it
    treated as white space and ignored?

    Is it possible to search for special characters ? ie if my query has ) then
    it should search for it and only if my search field has ) , it should give
    me a hit.

    Regards,
    Radha
  • Simon Willnauer at Jun 24, 2009 at 6:24 pm
    Beside choosing the right analyzer you could run into problems if you
    use a query parser as it will interpret you parentesis.

    simon

    On Wed, Jun 24, 2009 at 8:11 PM, Erick Ericksonwrote:
    First, I highly, highly recommend you get a copy of Luke to examineyour
    index. It'll also help you understand the role of Analyzers.

    Your first problem is that StandardAnalyzer probably removes
    the open and close parens. See:
    http://lucene.apache.org/java/2_4_1/api/index.html
    so you can't search on them *even if* you escape the
    terms in your query parsing correctly, see:
    http://lucene.apache.org/java/2_3_2/queryparsersyntax.html#Escaping Special
    Characters

    You want to understand the implications of whatever
    analyzer you choose, or progress will be...er...difficult <G>.

    Luke will allow you to try different Analyzers and see the results of
    parsing
    queries, which will be a fine place to start...

    Best
    Erick
    On Wed, Jun 24, 2009 at 1:30 PM, Radha Sreedharan wrote:

    Hi all,

    I am using a Standard analyzer on both my search field and my query.
    I use a  SpanNearQuery to search on the search field.
    One of the query terms has  special characters like ( - round open bracket
    and ) - round close bracket  : How does Lucene handle this?
    Also, the search field has ( and  ) : How does Lucene handle this? Is it
    treated as white space and ignored?

    Is it possible to search for special characters ? ie if my query has ) then
    it should search for it and only if my search field has ) , it should give
    me a hit.

    Regards,
    Radha
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedJun 24, '09 at 5:30p
activeJun 24, '09 at 6:24p
posts3
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase