Lucene++ - a full-featured, c++ search engine
API Documentation


Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Protected Member Functions
Lucene::DateField Class Reference

Provides support for converting dates to strings and vice-versa. The strings are structured so that lexicographic sorting orders by date, which makes them suitable for use as field values and search terms. More...

#include <DateField.h>

+ Inheritance diagram for Lucene::DateField:

Public Member Functions

virtual ~DateField ()
 
virtual String getClassName ()
 
boost::shared_ptr< DateFieldshared_from_this ()
 
- Public Member Functions inherited from Lucene::LuceneObject
virtual ~LuceneObject ()
 
virtual void initialize ()
 Called directly after instantiation to create objects that depend on this object being fully constructed.
 
virtual LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Return clone of this object.
 
virtual int32_t hashCode ()
 Return hash code for this object.
 
virtual bool equals (const LuceneObjectPtr &other)
 Return whether two objects are equal.
 
virtual int32_t compareTo (const LuceneObjectPtr &other)
 Compare two objects.
 
virtual String toString ()
 Returns a string representation of the object.
 
- Public Member Functions inherited from Lucene::LuceneSync
virtual ~LuceneSync ()
 
virtual SynchronizePtr getSync ()
 Return this object synchronize lock.
 
virtual LuceneSignalPtr getSignal ()
 Return this object signal.
 
virtual void lock (int32_t timeout=0)
 Lock this object using an optional timeout.
 
virtual void unlock ()
 Unlock this object.
 
virtual bool holdsLock ()
 Returns true if this object is currently locked by current thread.
 
virtual void wait (int32_t timeout=0)
 Wait for signal using an optional timeout.
 
virtual void notifyAll ()
 Notify all threads waiting for signal.
 

Static Public Member Functions

static String _getClassName ()
 
static const String & MIN_DATE_STRING ()
 
static const String & MAX_DATE_STRING ()
 
static String dateToString (const boost::posix_time::ptime &date)
 Converts a Date to a string suitable for indexing.
 
static String timeToString (int64_t time)
 Converts a millisecond time to a string suitable for indexing.
 
static int64_t stringToTime (const String &s)
 Converts a string-encoded date into a millisecond time.
 

Static Protected Member Functions

static int32_t DATE_LEN ()
 

Additional Inherited Members

- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 
- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Detailed Description

Provides support for converting dates to strings and vice-versa. The strings are structured so that lexicographic sorting orders by date, which makes them suitable for use as field values and search terms.

Note that this class saves dates with millisecond granularity, which is bad for TermRangeQuery and PrefixQuery, as those queries are expanded to a BooleanQuery with a potentially large number of terms when searching. Thus you might want to use DateTools instead.

Note: dates before 1970 cannot be used, and therefore cannot be indexed when using this class. See DateTools for an alternative without such a limitation.

Another approach is NumericUtils, which provides a sortable binary representation (prefix encoded) of numeric values, which date/time are. For indexing a Date or Calendar, just get the unix timestamp as long using Date#getTime or Calendar#getTimeInMillis and index this as a numeric value with NumericField and use NumericRangeQuery to query it.

Deprecated:
If you build a new index, use DateTools or NumericField instead. This class is included for use with existing indices and will be removed in a future release (possibly Lucene 4.0).

Constructor & Destructor Documentation

◆ ~DateField()

virtual Lucene::DateField::~DateField ( )
virtual

Member Function Documentation

◆ _getClassName()

static String Lucene::DateField::_getClassName ( )
inlinestatic

◆ DATE_LEN()

static int32_t Lucene::DateField::DATE_LEN ( )
staticprotected

◆ dateToString()

static String Lucene::DateField::dateToString ( const boost::posix_time::ptime &  date)
static

Converts a Date to a string suitable for indexing.

◆ getClassName()

virtual String Lucene::DateField::getClassName ( )
inlinevirtual

◆ MAX_DATE_STRING()

static const String & Lucene::DateField::MAX_DATE_STRING ( )
static

◆ MIN_DATE_STRING()

static const String & Lucene::DateField::MIN_DATE_STRING ( )
static

◆ shared_from_this()

boost::shared_ptr< DateField > Lucene::DateField::shared_from_this ( )
inline

◆ stringToTime()

static int64_t Lucene::DateField::stringToTime ( const String &  s)
static

Converts a string-encoded date into a millisecond time.

◆ timeToString()

static String Lucene::DateField::timeToString ( int64_t  time)
static

Converts a millisecond time to a string suitable for indexing.


The documentation for this class was generated from the following file:

clucene.sourceforge.net