本文整理汇总了C#中Lucene.Net.QueryParsers.QueryParser.SetDateResolution方法的典型用法代码示例。如果您正苦于以下问题:C# QueryParser.SetDateResolution方法的具体用法?C# QueryParser.SetDateResolution怎么用?C# QueryParser.SetDateResolution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.QueryParsers.QueryParser
的用法示例。
在下文中一共展示了QueryParser.SetDateResolution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDateRange
public virtual void TestDateRange()
{
System.String startDate = GetLocalizedDate(2002, 1, 1, false);
System.String endDate = GetLocalizedDate(2002, 1, 4, false);
System.Globalization.Calendar calendar = new System.Globalization.GregorianCalendar();
System.DateTime endDateExpected = new System.DateTime(2002, 1, 4, 23, 59, 59, 999, calendar);
System.String defaultField = "default";
System.String monthField = "month";
System.String hourField = "hour";
QueryParser qp = new QueryParser("field", new SimpleAnalyzer());
// Don't set any date resolution and verify if DateField is used
System.DateTime tempAux = endDateExpected;
AssertDateRangeQueryEquals(qp, defaultField, startDate, endDate, tempAux, null);
// set a field specific date resolution
qp.SetDateResolution(monthField, DateTools.Resolution.MONTH);
// DateField should still be used for defaultField
System.DateTime tempAux2 = endDateExpected;
AssertDateRangeQueryEquals(qp, defaultField, startDate, endDate, tempAux2, null);
// set default date resolution to MILLISECOND
qp.SetDateResolution(DateTools.Resolution.MILLISECOND);
// set second field specific date resolution
qp.SetDateResolution(hourField, DateTools.Resolution.HOUR);
// for this field no field specific date resolution has been set,
// so verify if the default resolution is used
System.DateTime tempAux3 = endDateExpected;
AssertDateRangeQueryEquals(qp, defaultField, startDate, endDate, tempAux3, DateTools.Resolution.MILLISECOND);
// verify if field specific date resolutions are used for these two fields
System.DateTime tempAux4 = endDateExpected;
AssertDateRangeQueryEquals(qp, monthField, startDate, endDate, tempAux4, DateTools.Resolution.MONTH);
System.DateTime tempAux5 = endDateExpected;
AssertDateRangeQueryEquals(qp, hourField, startDate, endDate, tempAux5, DateTools.Resolution.HOUR);
}