lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: DateFilter on UnStored field
Date Mon, 14 Feb 2005 13:54:46 GMT

On Feb 14, 2005, at 6:27 AM, Sanyi wrote:
>> However, DateFilter will not work on fields indexed as "2004-11-05".
>> DateFilter only works on fields that were indexed using the DateField.
>
> Well, can you post here a short example?
> When I currently type "xxx.UnStored(.." I can simply type 
> "xxx.DateField(.." ?
> Does it take strings like "2004-11-05"?

DateField has a utility method to return a String:

	DateField.timeToString(file.lastModified())

You'd use that String to pass to Field.UnStored.

I recommend, though, that you use a different format, such as the 
YYYY-MM-DD format you're using.

>> One option is to use a QueryFilter instead, filtering with a
>> RangeQuery.
>
> I've read somewhere that classic range filtering can easily exceed the 
> maximum number of boolean
> query clauses. I need to filter a very large range of dates with day 
> accuracy and I don't want to
> increase the max. clause count to very high values. So, I decided to 
> use DateFilter which has no
> such problems AFAIK.

Right!

In Lucene's latest codebase (though not in 1.4.x) includes RangeFilter 
which would do the trick for you.  If you want to stick with Lucene 
1.4.x, that's fine... just grab the code for that filter and use it as 
a custom filter - its compatible with 1.4.x.

> How much impact does DateFilter have on search times?

It depends on whether you instantiate a new filter for each search.  
Building a filter requires scanning through the terms in the index to 
build BitSet for the documents that fall in that range.  Filters are 
best used over multiple searches.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message