Re: Problem with Range

2002-11-23 Thread Michael Caughey
Correct but actually it would be  ( DATE:[null - 20020101])  with spaces
around the -.


- Original Message -
From: Clemens Marschner [EMAIL PROTECTED]
To: Lucene Users List [EMAIL PROTECTED]
Sent: Saturday, November 23, 2002 12:18 PM
Subject: Re: Problem with Range


 This probably does not answer your question, but may be a side effect:

if(start!=null || end!=null){
  buff.append( ( DATE:[);
  buff.append(start);
  buff.append( - );
  buff.append(end);
  buff.append(] ) );
  fieldList.add(DATE);

 This implies that start OR end can be null, producing something like (
 DATE:[null-20020101])




 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Date Range - I've searched FAQs and mail list archive..... no help..... Really

2002-11-22 Thread Michael Caughey
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 MMdd.

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