Odd.  Query.toString() and back to Query via parser are not guaranteed
to be consistent but it looks pretty straightforward in this case.

Maybe Searcher.explain would give a clue.  Or post a minimal
self-contained program or test case that demonstrates this.  Or try a
later version of lucene.


--
Ian.


On Thu, Mar 25, 2010 at 11:04 PM, Brian Pontarelli <br...@pontarelli.com> wrote:
> I'm new to the list and I'm having an issue that I wanted to ask about quick. 
> I'm using Lucene version 2.4.1
>
> I recently rewrote a query to use the Query classes rather than a String and 
> QueryParser. The search results between the two queries are now in different 
> orders while the number of results are the same. I have one caveat with my 
> change, I still use QueryParser for part of it so that I can easily handle 
> quoting.
>
> Here's some pseudo code:
>
> Old Way
> QueryParser parser = new QueryParser("words", analyzer);
> Query q = parser.parse("+words:(one two) +year:[1950 2010]");
> System.out.println("Old query is " + q);
>
> New Way
> BooleanQuery q = new BooleanQuery();
> QueryParser parser = new QueryParser("words", analyzer);
> q.add(parser.parse("one two"), Occur.MUST);
> q.add(new RangeQuery(new Term("year", 1950), new Term("year", 2010), true), 
> Occur.MUST);
> System.out.println("New query is " + q);
>
> My first thought was that the queries were ending up actually being different 
> queries. To verify, I do a toString on the two different queries and they are 
> the same. That output is:
>
> Old query is +(words:one words:two) +year:[1950 TO 2010]
> New query is +(words:one words:two) +year:[1950 TO 2010]
>
> So, I'm sorta stuck as to what to do next in order to figure this out. I'm 
> thinking that it has to do with the QueryParser usage in my "New Way", but 
> I'm not sure how that would effect the ordering.
>
> Anyone have experience with this or other things I can try?
>
> Thanks,
> -bp
>
>
>
>

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

Reply via email to