FAQ
Hi,

How do i make sure lucene gives me back relevant search results when my
input string contains terms like c++? Lucene seems to ignore ++ characters.

Thanks

--
View this message in context: http://www.nabble.com/Handling-%2B-as-a-special-character-in-Lucene-search-tp26002815p26002815.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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

Search Discussions

  • Ian Lea at Oct 22, 2009 at 8:50 am
    You need to make sure that these terms are getting indexed, by using
    an analyzer that won't drop them and using Luke to check. Then, if
    you are using QueryParser, you'll need to escape the special
    characters e.g. c\+\+. See
    http://lucene.apache.org/java/2_9_0/queryparsersyntax.html#Escaping%20Special%20Characters.
    And use the same analyzer at query time.

    Google for something like lucene special characters for more info.


    --
    Ian.



    On Thu, Oct 22, 2009 at 2:40 AM, mitu2009 wrote:

    Hi,

    How do i make sure lucene gives me back relevant search results when my
    input string contains terms like c++? Lucene seems to ignore ++ characters.

    Thanks

    --
    View this message in context: http://www.nabble.com/Handling-%2B-as-a-special-character-in-Lucene-search-tp26002815p26002815.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Koji Sekiguchi at Oct 22, 2009 at 12:36 pm
    Or you can use MappingCharFilter if you are using Lucene 2.9.
    You can convert "c++" into "cplusplus" prior to running Tokenizer.

    Koji

    --
    http://www.rondhuit.com/en/



    Ian Lea wrote:
    You need to make sure that these terms are getting indexed, by using
    an analyzer that won't drop them and using Luke to check. Then, if
    you are using QueryParser, you'll need to escape the special
    characters e.g. c\+\+. See
    http://lucene.apache.org/java/2_9_0/queryparsersyntax.html#Escaping%20Special%20Characters.
    And use the same analyzer at query time.

    Google for something like lucene special characters for more info.


    --
    Ian.



    On Thu, Oct 22, 2009 at 2:40 AM, mitu2009 wrote:

    Hi,

    How do i make sure lucene gives me back relevant search results when my
    input string contains terms like c++? Lucene seems to ignore ++ characters.

    Thanks

    --
    View this message in context: http://www.nabble.com/Handling-%2B-as-a-special-character-in-Lucene-search-tp26002815p26002815.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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

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



    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Mitu2009 at Oct 23, 2009 at 4:38 pm
    Code details: When I execute this line,I get a blank search query.

    queryField =
    multiFieldQueryParser.Parse(inpKeywords);keywordsQuery.Add(queryField,
    BooleanClause.Occur.SHOULD);And here is my custom analyzer:

    public class CustomAnalyzer : Analyzer { private static readonly
    WhitespaceAnalyzer whitespaceAnalyzer = new WhitespaceAnalyzer(); public
    override TokenStream TokenStream(String fieldName, System.IO.TextReader
    reader) { TokenStream result =
    whitespaceAnalyzer.TokenStream(fieldName, reader); result = new
    StandardTokenizer(reader); result = new LowerCaseFilter(result);
    result = new StopFilter(result, stop_words); return result;
    }}And I'm executing search query this way:

    indexSearcher.Search(searchQuery, collector);QueryParser has Escape(string
    s) method but MultiFieldQueryParser does not seem to have one.Am using
    Lucene.net version 2.1.0.3


    Thanks for reading.



    mitu2009 wrote:
    How do i make sure lucene gives me back relevant search results when my
    input string contains terms like c++? Lucene seems to ignore ++
    characters.

    Code details: When I execute this line,I get a blank search query.

    queryField =
    multiFieldQueryParser.Parse(inpKeywords);keywordsQuery.Add(queryField,
    BooleanClause.Occur.SHOULD);And here is my custom analyzer:

    public class CustomAnalyzer : Analyzer { private static readonly
    WhitespaceAnalyzer whitespaceAnalyzer = new WhitespaceAnalyzer();
    public override TokenStream TokenStream(String fieldName,
    System.IO.TextReader reader) { TokenStream result =
    whitespaceAnalyzer.TokenStream(fieldName, reader); result = new
    StandardTokenizer(reader); result = new
    LowerCaseFilter(result); result = new StopFilter(result,
    stop_words); return result; }}And I'm executing search
    query this way:

    indexSearcher.Search(searchQuery, collector);

    QueryParser has Escape(string s) method but MultiFieldQueryParser does not
    seem to have one.Am using Lucene.net version 2.1.0.3

    --
    View this message in context: http://www.nabble.com/Handling-%2B-as-a-special-character-in-Lucene-search-tp26002815p26029632.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    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
postedOct 22, '09 at 1:41a
activeOct 23, '09 at 4:38p
posts4
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase