Michael,
I use range query extensively. I can't help with the code (Otis is
apparently looking at that aspect), but I have a couple of quick suggestions
to try:
1. make DATE lowercase, so the term is date:[20021101 - 20021130]
2. try using QueryParser in lieu of MultiQueryParser and see if that works
(it does for me).
Also, you say you're using 1.2. Just keep in mind that the range query
syntax was changed in 1.3.1 to require the following form: date:[20021101 TO
20021130], and if you're searching up to a date, instead of date:[null -
20021130] you'll need to use date:[0 TO 20021130].
HTH,
Terry
----- Original Message -----
From: "Michael Caughey" <[EMAIL PROTECTED]>
To: "Lucene Users List" <[EMAIL PROTECTED]>
Sent: Saturday, November 23, 2002 1:44 AM
Subject: Date Range - I've searched FAQs and mail list archive..... no
help..... Really
Part of my problem seems to be that the Range Query Object isn't acting as
it should as per the FAQ and other mail list entries.
I'm using Lucene 1.2
I have a field in my index called DATE. I'd like to do a date range search
on it. I am using Strings in the format of yyyyMMdd.
I have the following dates in my Index:
20021105
20021126
20021113
20021115
20021103
20021125
When I use the follwing code to search, I get an exception:
*NOTE: I'm using the MultiFieldQueryParser becuase In some cases I check
other field, I've simplified this one to demonstrate (and run my tests
isolated from other factors)
IndexSearcher search = new IndexSearcher("myindex");
SimpleAnalyzer analyzer = new SimpleAnalyzer();
String[] fields = new String[1];
fields[0] = "DATE"
String buff = "( DATE:[20021101 - 20021131] )";
Query query = MultiFieldQueryParser.parse(buff, fields, analyzer);
searcher.search(query);
I get the following error:
java.lang.IllegalArgumentException: At least one term must be non-null
if buff = "( DATE:20021101 - 20021131 )";
as well as
if buff = "( DATE:(20021101 - 20021131 ))";
I simply get no results.
I have added the date to the document by both
Field.Text("DATE", dateStr);
and
Field.Keyword("DATE", dateStr);
I have also tried to build the queries up creating Objects. One of the
things I notice is that if I use the RangeQuery Object there are no spaces
on either side of the "-".
The documents which I created have the following Fields:
TITLE, DESCRIPTION and DATE.
If I search on TITLE or DESCRIPTION or a combination of both I get results
just fine.
Am I doing something stupid, or is this a bug? Seems to based on what I
read that the example above where String buff = "( DATE:[20021101 -
20021131] )"; is correct and should work.
I published the complete source in an earlier posting called "Problem with
Range". It also contains a stack trace of the error.
Thanks in advance,
Michael
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>