Lucene.Net
3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
|
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...
Static Public Member Functions | |
static System.String | MIN_DATE_STRING () |
static System.String | MAX_DATE_STRING () |
static System.String | DateToString (System.DateTime date) |
Converts a Date to a string suitable for indexing. | |
static System.String | TimeToString (long time) |
Converts a millisecond time to a string suitable for indexing. | |
static long | StringToTime (System.String s) |
Converts a string-encoded date into a millisecond time. | |
static System.DateTime | StringToDate (System.String s) |
Converts a string-encoded date into a Date object. | |
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 DateTime, convert it to unix timestamp as long
and index this as a numeric value with NumericField and use NumericRangeQuery{T} 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 (possibly Lucene 4.0) </deprecated>
Definition at line 63 of file DateField.cs.
|
static |
Converts a Date to a string suitable for indexing.
<throws> RuntimeException if the date specified in the </throws>
method argument is before 1970
Definition at line 91 of file DateField.cs.
|
static |
Definition at line 78 of file DateField.cs.
|
static |
Definition at line 73 of file DateField.cs.
|
static |
Converts a string-encoded date into a Date object.
Definition at line 129 of file DateField.cs.
|
static |
Converts a string-encoded date into a millisecond time.
Definition at line 124 of file DateField.cs.
|
static |
Converts a millisecond time to a string suitable for indexing.
<throws> RuntimeException if the time specified in the </throws>
method argument is negative, that is, before 1970
Definition at line 101 of file DateField.cs.