I can use Lucene.net for string indexing and searching, but, i want to search documents by, between two date. can you share any code example for search between two date? i find one sample in stackoverflow, but it's too old (9 year ago) and can't run with my Lucene.net version. Thanks,
Lucene.NET does not have a field type of date or date range query. So there are typically two choices for how to store, index and search dates.
Then depending on which you chose to go with then you can use a TermRangeQuery
or a NumericRangeQuery
for doing the search. Both approaches are able to handle date only or date and time.
It's also worth knowing that Lucene.NET contains a DataTools static class that has utility methods for converting a DateTime to a string and back with different levels of resolution, ie
"yyyy";
"yyyyMM";
"yyyyMMdd";
"yyyyMMddHH";
"yyyyMMddHHmm";
"yyyyMMddHHmmss";
"yyyyMMddHHmmssfff";
Hopefully that's enough to get you going.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.