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 Warren <wa...@clarksnutrition.com> on 2007/10/25 06:33:06 UTC

Same query different results?

I have two two similar query's that give me the same results when I run them
in Luke, but when I run them in my app, one of the querys gives me the
correct results and the other query gives me no results. I am using
StandardAnalyzer in both Luke and my app.

Query 1:
This query works correctly in my app and Luke

+(upc:almonds description:almonds content:almonds) +dept:bulk +zone:1

Query 2:
This query works correctly in Luke but returns no results in my app

+(upc:almonds description:almonds content:almonds) +dept:"Bulk" +zone:1

My app code:

Directory dir = FSDirectory.getDirectory(indexDir);
IndexSearcher searcher = new IndexSearcher(dir);
Hits hits = searcher.search(query);

The only difference is that the term "bulk" is quoted in one query and not
quoted in the other. Shouldn't both of these querys get the same results
when useing StandardAnalyzer? Isn't one term quoted the same as one term
unquoted?

What am I missing?

Thanks,

Warren


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


RE: Same query different results?

Posted by Warren <wa...@clarksnutrition.com>.

> -----Original Message-----
> From: Karl Wettin [mailto:karl.wettin@gmail.com]
> Sent: Wednesday, October 24, 2007 10:25 PM
> To: java-user@lucene.apache.org
> Subject: Re: Same query different results?
> 
> 
> 
> 25 okt 2007 kl. 06.33 skrev Warren:
> 
> > This query works correctly in my app and Luke
> >
> > +(upc:almonds description:almonds content:almonds) +dept:bulk +zone:1
> >
> > Query 2:
> > This query works correctly in Luke but returns no results in my app
> >
> > +(upc:almonds description:almonds content:almonds) +dept:"Bulk"  
> > +zone:1
> >
> > My app code:
> >
> > Directory dir = FSDirectory.getDirectory(indexDir);
> > IndexSearcher searcher = new IndexSearcher(dir);
> > Hits hits = searcher.search(query);
> 
> How do you create the query? If using a query parser, how do you  
> instantiate the query parser?
> 
> >
> > The only difference is that the term "bulk" is quoted in one query  
> > and not
> 
> There is also the upper case B.
> 
> Comparing rewritten and queries and their weight explenation might  
> prove helpful.
> 
> -- 
> karl

upc:almonds was created with QueryParser
description:almonds was created with QueryParser
content:almonds was created with QueryParser

All of the above was placed in a BooleanQuery

+dept:"Bulk" was created with a PhraseQuery

+zone:1 was created with QueryParser

The three different items above were all placed in a BooleanQuery

QueryParser was created this way:

QueryParser parser = new QueryParser(field, new StandardAnalyzer());
query = parser.parse(searchString);

I can get it to work if I replace the PhraseQuery with QueryParser;

Whats up with that?


> 
> ---------------------------------------------------------------------
> 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


Re: Same query different results?

Posted by Karl Wettin <ka...@gmail.com>.
25 okt 2007 kl. 06.33 skrev Warren:

> This query works correctly in my app and Luke
>
> +(upc:almonds description:almonds content:almonds) +dept:bulk +zone:1
>
> Query 2:
> This query works correctly in Luke but returns no results in my app
>
> +(upc:almonds description:almonds content:almonds) +dept:"Bulk"  
> +zone:1
>
> My app code:
>
> Directory dir = FSDirectory.getDirectory(indexDir);
> IndexSearcher searcher = new IndexSearcher(dir);
> Hits hits = searcher.search(query);

How do you create the query? If using a query parser, how do you  
instantiate the query parser?

>
> The only difference is that the term "bulk" is quoted in one query  
> and not

There is also the upper case B.

Comparing rewritten and queries and their weight explenation might  
prove helpful.

-- 
karl

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