You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Devi pulaparti <pv...@gmail.com> on 2013/10/10 10:27:46 UTC

queries with "&&" doesn't work but "AND" does

In our search application, queries like  test && usage  do not return
correct results but  test AND usage works fine.  So queries with "&&"
doesn't work but "AND" does. We are using default queryparser with standard
analyzer. Could some one please help me resolving this. please let me know
if you need more details of implementation.

Re: queries with "&&" doesn't work but "AND" does

Posted by Ian Lea <ia...@gmail.com>.
Looks like you've got some XML processing in there somewhere.  Nothing
to do with lucene.  This code:

    public static void main(String[] _args) throws Exception {
QueryParser qp = new QueryParser(Version.LUCENE_44,
"x",
new StandardAnalyzer(Version.LUCENE_44));
for (String s : _args) {
   System.out.printf("%s: %s\n", s, qp.parse(s));
}
    }

produces this output:

hello && goodbye: +x:hello +x:goodbye
hello AND goodbye: +x:hello +x:goodbye


--
Ian.


On Thu, Oct 10, 2013 at 11:32 AM, Devi pulaparti <pv...@gmail.com> wrote:
> toString output by queryparser.parse()  for query   TEST && USAGE  is "
> content:TEST content:\"amp amp\" content:USAGE "  .
> and for query  TEST AND USAGE is "+content:TEST +content:USAGE"
> any idea why is analyzer treating && as content?
>
>
>
>
> On Thu, Oct 10, 2013 at 2:50 PM, Alan Burlison <al...@gmail.com>wrote:
>
>> On 10/10/2013 09:27, Devi pulaparti wrote:
>>
>>  In our search application, queries like  test && usage  do not return
>>> correct results but  test AND usage works fine.  So queries with "&&"
>>> doesn't work but "AND" does. We are using default queryparser with
>>> standard
>>> analyzer. Could some one please help me resolving this. please let me know
>>> if you need more details of implementation.
>>>
>>
>> Most likely cause is that the analyzer is discarding non-alphanumeric
>> tokens. Use toString on the query returned by queryparser.parse() to see
>> what's in there.
>>
>> --
>> Alan Burlison
>> --
>>

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


Re: queries with "&&" doesn't work but "AND" does

Posted by Nicola Buso <nb...@ebi.ac.uk>.
On Thu, 2013-10-10 at 16:02 +0530, Devi pulaparti wrote:
> toString output by queryparser.parse()  for query   TEST && USAGE  is "
> content:TEST content:\"amp amp\" content:USAGE "  .
> and for query  TEST AND USAGE is "+content:TEST +content:USAGE"
> any idea why is analyzer treating && as content?
seam something is encoding && before giving it to the parser.

Nicola.
> 
> 
> 
> 
> On Thu, Oct 10, 2013 at 2:50 PM, Alan Burlison <al...@gmail.com>wrote:
> 
> > On 10/10/2013 09:27, Devi pulaparti wrote:
> >
> >  In our search application, queries like  test && usage  do not return
> >> correct results but  test AND usage works fine.  So queries with "&&"
> >> doesn't work but "AND" does. We are using default queryparser with
> >> standard
> >> analyzer. Could some one please help me resolving this. please let me know
> >> if you need more details of implementation.
> >>
> >
> > Most likely cause is that the analyzer is discarding non-alphanumeric
> > tokens. Use toString on the query returned by queryparser.parse() to see
> > what's in there.
> >
> > --
> > Alan Burlison
> > --
> >



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


Re: queries with "&&" doesn't work but "AND" does

Posted by Devi pulaparti <pv...@gmail.com>.
toString output by queryparser.parse()  for query   TEST && USAGE  is "
content:TEST content:\"amp amp\" content:USAGE "  .
and for query  TEST AND USAGE is "+content:TEST +content:USAGE"
any idea why is analyzer treating && as content?




On Thu, Oct 10, 2013 at 2:50 PM, Alan Burlison <al...@gmail.com>wrote:

> On 10/10/2013 09:27, Devi pulaparti wrote:
>
>  In our search application, queries like  test && usage  do not return
>> correct results but  test AND usage works fine.  So queries with "&&"
>> doesn't work but "AND" does. We are using default queryparser with
>> standard
>> analyzer. Could some one please help me resolving this. please let me know
>> if you need more details of implementation.
>>
>
> Most likely cause is that the analyzer is discarding non-alphanumeric
> tokens. Use toString on the query returned by queryparser.parse() to see
> what's in there.
>
> --
> Alan Burlison
> --
>

Re: queries with "&&" doesn't work but "AND" does

Posted by Alan Burlison <al...@gmail.com>.
On 10/10/2013 09:27, Devi pulaparti wrote:

> In our search application, queries like  test && usage  do not return
> correct results but  test AND usage works fine.  So queries with "&&"
> doesn't work but "AND" does. We are using default queryparser with standard
> analyzer. Could some one please help me resolving this. please let me know
> if you need more details of implementation.

Most likely cause is that the analyzer is discarding non-alphanumeric 
tokens. Use toString on the query returned by queryparser.parse() to see 
what's in there.

-- 
Alan Burlison
--

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