lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven A Rowe <>
Subject RE: lucene 3.0.3 | QueryParser | MultiFieldQueryParser
Date Wed, 27 Apr 2011 15:37:06 GMT

The problem is definitely the analyzer you are passing to QueryParser or MultiFieldQueryParser,
and not the parser itself.

The following tests succeed using KeywordAnalyzer, which is a pass-through analyzer (the output
is the same as the input):

  public void testSharpQP() throws Exception {
    Analyzer analyzer = new KeywordAnalyzer();
    QueryParser qp = new QueryParser
        (Version.LUCENE_30, "default_field", analyzer);
    assertEquals("+c#", qp.parse
        ("c# AND .net").toString("default_field"));

  public void testSharpMFQP() throws Exception {
    Analyzer analyzer = new KeywordAnalyzer();
    String[] fields = { "one", "two"};
    MultiFieldQueryParser mfqp = new MultiFieldQueryParser
        (Version.LUCENE_30, fields, analyzer);
    assertEquals("+(one:c# two:c#) +(", 
                 mfqp.parse("c# AND .net").toString());


> -----Original Message-----
> From: Ranjit Kumar []
> Sent: Wednesday, April 27, 2011 3:24 AM
> To:;
> Subject: Re: lucene 3.0.3 | QueryParser | MultiFieldQueryParser
> Hi,
> while creating index with the help of  lucene standardAnalyzer, we cannot
> make difference between c, c++ and c# as lucene do not create index for
> c++ and c#. To make the difference between these term I need to change
> the grammar of lucene with the help of jFlex, it force me to create my
> own custom analyzer.
> While I am searching for single term like c# I get correct result (also
> in the case of c++) So, lucene make index for C++ and c# . Also do not
> need to use any Parser. Hence,  jFlex doing it work properly.
> But, when I am trying to search for multiple Boolean query like c# AND
> .net  I need to use  MultiFieldQueryParser to get correct
> result(document). Then Parser stripping off # but do not dot(.) so query
> became c AND .net
> Also, I have made changes for,, .net all these work
> properly with MultiFieldQueryParser except c#
> Thanks & Regards,
> Ranjit Kumar
> =========================================================================
> ========================== Private, Confidential and Privileged. This e-
> mail and any files and attachments transmitted with it are confidential
> and/or privileged. They are intended solely for the use of the intended
> recipient. The content of this e-mail and any file or attachment
> transmitted with it may have been changed or altered without the consent
> of the author. If you are not the intended recipient, please note that
> any review, dissemination, disclosure, alteration, printing, circulation
> or Transmission of this e-mail and/or any file or attachment transmitted
> with it, is prohibited and may be unlawful. If you have received this e-
> mail or any file or attachment transmitted with it in error please notify
> OTS Solutions at
> =========================================================================
> ==========================
View raw message