DLESE Tools
v1.6.0

org.dlese.dpc.index.search
Class DateRangeFilter

java.lang.Object
  extended by org.apache.lucene.search.Filter
      extended by org.dlese.dpc.index.search.DateRangeFilter
All Implemented Interfaces:
Serializable

public class DateRangeFilter
extends org.apache.lucene.search.Filter

Filters Lucene search results based on a range of Dates or times. This implements similar functionality as the the deprecated Lucene 1.4 DateFilter. Assumes that fields are indexed using the Lucene DateTools format of yyyyMMddHHmmss, to a granularity of seconds.

Author:
John Weatherley
See Also:
Serialized Form

Constructor Summary
DateRangeFilter(String f, Date from, Date to)
          Constructs a filter for field f matching dates between from and to inclusively.
 
Method Summary
static DateRangeFilter After(String field, Date date)
          Constructs a filter for field f matching dates on or after date.
static DateRangeFilter After(String field, long time)
          Constructs a filter for field f matching times on or after time.
static DateRangeFilter Before(String field, Date date)
          Constructs a filter for field f matching dates on or before date.
static DateRangeFilter Before(String field, long time)
          Constructs a filter for field f matching times on or before time.
 org.apache.lucene.search.DocIdSet getDocIdSet(org.apache.lucene.index.IndexReader reader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateRangeFilter

public DateRangeFilter(String f,
                       Date from,
                       Date to)
Constructs a filter for field f matching dates between from and to inclusively. Uses time resolution to seconds.

Parameters:
f - The field name
from - From Date
to - To Date
Method Detail

Before

public static DateRangeFilter Before(String field,
                                     Date date)
Constructs a filter for field f matching dates on or before date. Uses time resolution to seconds.

Parameters:
field - Field name
date - The Date
Returns:
The Filter

After

public static DateRangeFilter After(String field,
                                    Date date)
Constructs a filter for field f matching dates on or after date. Uses time resolution to seconds.

Parameters:
field - Field name
date - The Date
Returns:
The Filter

Before

public static DateRangeFilter Before(String field,
                                     long time)
Constructs a filter for field f matching times on or before time. Uses time resolution to seconds.

Parameters:
field - Field name
time - The time
Returns:
The Filter

After

public static DateRangeFilter After(String field,
                                    long time)
Constructs a filter for field f matching times on or after time. Uses time resolution to seconds.

Parameters:
field - Field name
time - The time
Returns:
The Filter

getDocIdSet

public org.apache.lucene.search.DocIdSet getDocIdSet(org.apache.lucene.index.IndexReader reader)
                                              throws IOException
Specified by:
getDocIdSet in class org.apache.lucene.search.Filter
Throws:
IOException

DLESE Tools
v1.6.0