lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Pontarelli <>
Subject Re: Strange issue with String vs. Query
Date Fri, 26 Mar 2010 15:32:05 GMT
Yeah. I was thinking about of those. I don't want to upgrade as it is in production. I can't
get a test case that reproduces the issue for some reason. I might need the production data
set to test with.

I'll definitely try an explain and see what the heck is going on.

For now, I just reverted to a String search and everything is good again. Not a huge fan,
but the change was fast and worked. I definitely think that the Query from  QueryParser doesn't
seem to mix well with BooleanQuery, which again seems odd.

Thanks for the reply.


On Mar 26, 2010, at 6:07 AM, Ian Lea wrote:

> 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 <> 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
>> 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:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message