Class DateTools
Provides support for converting dates to strings and vice-versa. The strings are structured so that lexicographic sorting orders them by date, which makes them suitable for use as field values and search terms.
This class also helps you to limit the resolution of your dates. Do not save dates with a finer resolution than you really need, as then RangeQuery and PrefixQuery will require more memory and become slower.
Compared to DateField the strings generated by the methods
in this class take slightly more space, unless your selected resolution
is set to Resolution.DAY
or lower.
Another approach is Lucene.Net.Util.NumericUtils, which provides
a sortable binary representation (prefix encoded) of numeric values, which
date/time are.
For indexing a long
and
index this as a numeric value with NumericField
and use NumericRangeQuery<T> to query it.
Inheritance
Namespace:
Assembly: Lucene.Net.NetCore.dll
Syntax
public class DateTools : object
Methods
Name | Description |
---|---|
DateToString(DateTime, DateTools.Resolution) | Converts a Date to a string suitable for indexing. |
Round(DateTime, DateTools.Resolution) | Limit a date's resolution. For example, the date |
Round(Int64, DateTools.Resolution) | Limit a date's resolution. For example, the date |
StringToDate(String) | Converts a string produced by |
StringToTime(String) | Converts a string produced by |
TimeToString(Int64, DateTools.Resolution) | Converts a millisecond time to a string suitable for indexing. |