I understand how Lucene.net can work for text indexing. Will I be able to efficiently search for documents based on a given date range? Or will Lucene.net just use text matching to match the dates?
+6
A:
Lucene.Net will just use text matching, so you'd need to format the dates correctly before adding to the index:
public static string Serialize(DateTime dateTime)
{
return dateTime.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture);
}
public static DateTime Deserialize(string str)
{
return DateTime.ParseExact(str, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
}
You can then, for example, perform a range based query to filter by date (e.g. 2006* to 2007* to include all dates in 2006 and 2007).
Stefan Schultze
2008-11-20 11:02:41
I know little to nothing about lucene as im just trying to teach myself, but this answer threw me off for a while because the milliseconds are missing from the datetime, you want (well i did) "yyyyMMddHHmmssfff"
Andrew Bullock
2009-06-24 12:56:37
Careful with running into problems going over maxClauseCount (default of 1024) as a RangeQuery expands under the covers to a BooleanQuery with all matching terms OR'd together. With dates (because they're indexed as text), the number of terms gets large quickly. See http://www.gossamer-threads.com/lists/lucene/java-user/34583
Ted
2009-08-23 08:31:04
A:
Hi,
I went in to trouble when i converted date in to yyyymmddHHmmssff. When i tried sorting the data, it gave me an exception that too big to convert..something. Hence i search and found then you need to have two columns. one in yyyymmdd and the other HHmmss, and then use Sort[] and give these two columns and then use. This will solve the issue.
Malay
2010-08-13 04:07:31