FAQ
I am working on lucene 2.0.0 trying to parse a query with my word "c++" as a
keywords but unfortunately it strips out my word as "c".

How can I parse a query like "c++" and "c#"?

Here are the codes

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;

class QueryTest {
public static void main (String [ ] args){

String keywords = "java c++";
QueryParser qp = new QueryParser("keywords", new StandardAnalyzer());
try {

System.err.println("Query - "+qp.parse(keywords).toString());

}catch (ParseException pe){
System.err.println("Error Caught: "+pe);
}
}

}
--
View this message in context: http://www.nabble.com/QueryParser-Strips-%22%2B%2B%22-out-of-my-word-%22c%2B%2B%22-tf3125890.html#a8660921
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.


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

Search Discussions

  • Doron Cohen at Jan 27, 2007 at 12:30 am
    Hi Joe,

    It must be the standard analyzer's work - try like this:
    new QueryParser("keywords", new WhitespaceAnalyzer())

    Regards,
    Doron

    Joe Tang <joe.tang@workmetro.com> wrote on 26/01/2007 15:48:31:
    I am working on lucene 2.0.0 trying to parse a query with my word "c++" as a
    keywords but unfortunately it strips out my word as "c".

    How can I parse a query like "c++" and "c#"?

    Here are the codes

    import org.apache.lucene.analysis.standard.StandardAnalyzer;
    import org.apache.lucene.queryParser.ParseException;
    import org.apache.lucene.queryParser.QueryParser;
    import org.apache.lucene.search.Query;

    class QueryTest {
    public static void main (String [ ] args){

    String keywords = "java c++";
    QueryParser qp = new QueryParser("keywords", new
    StandardAnalyzer());
    try {

    System.err.println("Query - "+qp.parse(keywords).toString());
    }catch (ParseException pe){
    System.err.println("Error Caught: "+pe);
    }
    }

    }
    --
    View this message in context: http://www.nabble.com/QueryParser-
    Strips-%22%2B%2B%22-out-of-my-word-%22c%2B%2B%22-tf3125890.html#a8660921
    Sent from the Lucene - Java Developer mailing list archive at Nabble.com.


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

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-dev-help@lucene.apache.org
  • Joe Tang at Jan 27, 2007 at 1:29 am
    Thanks for you reply Doron. It works partly on me.

    How should I customize the Analyzer so as to have the functionality of
    StandardAnalyzer as well as not stripping out some of the charactors?

    Regards,
    Joe



    Doron Cohen wrote:
    Hi Joe,

    It must be the standard analyzer's work - try like this:
    new QueryParser("keywords", new WhitespaceAnalyzer())

    Regards,
    Doron

    Joe Tang <joe.tang@workmetro.com> wrote on 26/01/2007 15:48:31:
    I am working on lucene 2.0.0 trying to parse a query with my word "c++" as a
    keywords but unfortunately it strips out my word as "c".

    How can I parse a query like "c++" and "c#"?

    Here are the codes

    import org.apache.lucene.analysis.standard.StandardAnalyzer;
    import org.apache.lucene.queryParser.ParseException;
    import org.apache.lucene.queryParser.QueryParser;
    import org.apache.lucene.search.Query;

    class QueryTest {
    public static void main (String [ ] args){

    String keywords = "java c++";
    QueryParser qp = new QueryParser("keywords", new
    StandardAnalyzer());
    try {

    System.err.println("Query - "+qp.parse(keywords).toString());
    }catch (ParseException pe){
    System.err.println("Error Caught: "+pe);
    }
    }

    }
    --
    View this message in context: http://www.nabble.com/QueryParser-
    Strips-%22%2B%2B%22-out-of-my-word-%22c%2B%2B%22-tf3125890.html#a8660921
    Sent from the Lucene - Java Developer mailing list archive at Nabble.com.


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

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

    --
    View this message in context: http://www.nabble.com/QueryParser-Strips-%22%2B%2B%22-out-of-my-word-%22c%2B%2B%22-tf3125890.html#a8661841
    Sent from the Lucene - Java Developer mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-dev-help@lucene.apache.org
  • Mike Klaas at Jan 27, 2007 at 3:01 am

    On 1/26/07, Joe Tang wrote:
    Thanks for you reply Doron. It works partly on me.

    How should I customize the Analyzer so as to have the functionality of
    StandardAnalyzer as well as not stripping out some of the charactors?
    Joe,

    See nutch's version of StandardAnalyzer: it adds a few rules to
    special case C++ and C#.
    (nutch-trunk/src/java/org/apache/nutch/analysis/NutchAnalysis.jj).
    You may be able to pluck those rules and insert them into Lucene's
    StandardAnalyzer (after recompiling with javaCC).

    -Mike

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categorieslucene
postedJan 26, '07 at 11:49p
activeJan 27, '07 at 3:01a
posts4
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase