FAQ
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

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
groupjava-user @
categorieslucene
postedMar 25, '10 at 11:04p
activeMar 27, '10 at 1:21a
posts4
users3
websitelucene.apache.org

People

Translate

site design / logo © 2021 Grokbase