Lucene++ - a full-featured, c++ search engine
API Documentation
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>
Public Member Functions | |
virtual | ~DateField () |
virtual String | getClassName () |
boost::shared_ptr< DateField > | shared_from_this () |
![]() | |
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. | |
![]() | |
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 | |
![]() | |
LuceneObject () | |
![]() | |
SynchronizePtr | objectLock |
LuceneSignalPtr | objectSignal |
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.
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).
|
virtual |
|
inlinestatic |
|
staticprotected |
|
static |
Converts a Date to a string suitable for indexing.
|
inlinevirtual |
|
static |
|
static |
|
inline |
|
static |
Converts a string-encoded date into a millisecond time.
|
static |
Converts a millisecond time to a string suitable for indexing.