当前位置: 首页>>代码示例>>Java>>正文


Java DateTools.Resolution方法代码示例

本文整理汇总了Java中org.apache.lucene.document.DateTools.Resolution方法的典型用法代码示例。如果您正苦于以下问题:Java DateTools.Resolution方法的具体用法?Java DateTools.Resolution怎么用?Java DateTools.Resolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.document.DateTools的用法示例。


在下文中一共展示了DateTools.Resolution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildFieldConfig

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
@Override
public void buildFieldConfig(FieldConfig fieldConfig) {
  DateTools.Resolution dateRes = null;
  Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

  if (dateResMap != null) {
    dateRes = dateResMap.get(
        fieldConfig.getField());
  }

  if (dateRes == null) {
    dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
  }

  if (dateRes != null) {
    fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
  }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:FieldDateResolutionFCListener.java

示例2: getDateResolution

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Returns the date resolution that is used by RangeQueries for the given field.
 * Returns null, if no default or field specific date resolution has been set
 * for the given field.
 *
 */
public DateTools.Resolution getDateResolution(String fieldName) {
  if (fieldName == null) {
    throw new IllegalArgumentException("Field cannot be null.");
  }

  if (fieldToDateResolution == null) {
    // no field specific date resolutions set; return default date resolution instead
    return this.dateResolution;
  }

  DateTools.Resolution resolution = fieldToDateResolution.get(fieldName);
  if (resolution == null) {
    // no date resolutions set for the given field; return default date resolution instead
    resolution = this.dateResolution;
  }

  return resolution;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:QueryParserBase.java

示例3: getDateResolution

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Returns the date resolution that is used by RangeQueries for the given field. Returns null, if no default or field specific date
 * resolution has been set for the given field.
 * 
 */
public DateTools.Resolution getDateResolution(String fieldName) {
	if (fieldName == null) {
		throw new IllegalArgumentException("Field cannot be null.");
	}

	if (fieldToDateResolution == null) {
		// no field specific date resolutions set; return default date resolution instead
		return this.dateResolution;
	}

	DateTools.Resolution resolution = fieldToDateResolution.get(fieldName);
	if (resolution == null) {
		// no date resolutions set for the given field; return default date resolution instead
		resolution = this.dateResolution;
	}

	return resolution;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:24,代码来源:QueryParser.java

示例4: setDateResolution

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Sets the date resolution used by RangeQueries for a specific field.
 *
 * @param fieldName field for which the date resolution is to be set
 * @param dateResolution date resolution to set
 */
public void setDateResolution(String fieldName, DateTools.Resolution dateResolution) {
  if (fieldName == null) {
    throw new IllegalArgumentException("Field cannot be null.");
  }

  if (fieldToDateResolution == null) {
    // lazily initialize HashMap
    fieldToDateResolution = new HashMap<>();
  }

  fieldToDateResolution.put(fieldName, dateResolution);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:QueryParserBase.java

示例5: setDateResolution

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * Sets the date resolution used by RangeQueries for a specific field.
 * 
 * @param fieldName field for which the date resolution is to be set
 * @param dateResolution date resolution to set
 */
public void setDateResolution(String fieldName, DateTools.Resolution dateResolution) {
	if (fieldName == null) {
		throw new IllegalArgumentException("Field cannot be null.");
	}

	if (fieldToDateResolution == null) {
		// lazily initialize HashMap
		fieldToDateResolution = new HashMap<String, DateTools.Resolution>();
	}

	fieldToDateResolution.put(fieldName, dateResolution);
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:19,代码来源:QueryParser.java

示例6: testDateRange

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
public void testDateRange() throws Exception {
  String startDate = getLocalizedDate(2002, 1, 1);
  String endDate = getLocalizedDate(2002, 1, 4);
  // we use the default Locale/TZ since LuceneTestCase randomizes it
  Calendar endDateExpected = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
  endDateExpected.clear();
  endDateExpected.set(2002, 1, 4, 23, 59, 59);
  endDateExpected.set(Calendar.MILLISECOND, 999);
  final String defaultField = "default";
  final String monthField = "month";
  final String hourField = "hour";
  StandardQueryParser qp = new StandardQueryParser();

  Map<CharSequence, DateTools.Resolution> dateRes =  new HashMap<>();
  
  // set a field specific date resolution    
  dateRes.put(monthField, DateTools.Resolution.MONTH);
  qp.setDateResolution(dateRes);

  // set default date resolution to MILLISECOND
  qp.setDateResolution(DateTools.Resolution.MILLISECOND);

  // set second field specific date resolution
  dateRes.put(hourField, DateTools.Resolution.HOUR);
  qp.setDateResolution(dateRes);

  // for this field no field specific date resolution has been set,
  // so verify if the default resolution is used
  assertDateRangeQueryEquals(qp, defaultField, startDate, endDate,
      endDateExpected.getTime(), DateTools.Resolution.MILLISECOND);

  // verify if field specific date resolutions are used for these two
  // fields
  assertDateRangeQueryEquals(qp, monthField, startDate, endDate,
      endDateExpected.getTime(), DateTools.Resolution.MONTH);

  assertDateRangeQueryEquals(qp, hourField, startDate, endDate,
      endDateExpected.getTime(), DateTools.Resolution.HOUR);
}
 
开发者ID:europeana,项目名称:search,代码行数:40,代码来源:TestQPHelper.java

示例7: getRangeQuery

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/**
 * @exception ParseException throw in overridden method to disallow
 */
protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException {
	if (lowercaseExpandedTerms) {
		part1 = part1.toLowerCase();
		part2 = part2.toLowerCase();
	}
	try {
		DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
		df.setLenient(true);
		Date d1 = df.parse(part1);
		Date d2 = df.parse(part2);
		if (inclusive) {
			// The user can only specify the date, not the time, so make sure
			// the time is set to the latest possible time of that date to really
			// include all documents:
			Calendar cal = Calendar.getInstance(locale);
			cal.setTime(d2);
			cal.set(Calendar.HOUR_OF_DAY, 23);
			cal.set(Calendar.MINUTE, 59);
			cal.set(Calendar.SECOND, 59);
			cal.set(Calendar.MILLISECOND, 999);
			d2 = cal.getTime();
		}
		DateTools.Resolution resolution = getDateResolution(field);
		if (resolution == null) {
			// no default or field specific date resolution has been set,
			// use deprecated DateField to maintain compatibility with
			// pre-1.9 Lucene versions.
			part1 = DateField.dateToString(d1);
			part2 = DateField.dateToString(d2);
		} else {
			part1 = DateTools.dateToString(d1, resolution);
			part2 = DateTools.dateToString(d2, resolution);
		}
	} catch (Exception e) {
	}

	return newRangeQuery(field, part1, part2, inclusive);
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:42,代码来源:QueryParser.java

示例8: assertDateRangeQueryEquals

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
public void assertDateRangeQueryEquals(PrecedenceQueryParser qp, String field,
    String startDate, String endDate, Date endDateInclusive,
    DateTools.Resolution resolution) throws Exception {
  assertQueryEquals(qp, field, field + ":[" + escapeDateString(startDate)
      + " TO " + escapeDateString(endDate) + "]", "["
      + getDate(startDate, resolution) + " TO "
      + getDate(endDateInclusive, resolution) + "]");
  assertQueryEquals(qp, field, field + ":{" + escapeDateString(startDate)
      + " TO " + escapeDateString(endDate) + "}", "{"
      + getDate(startDate, resolution) + " TO "
      + getDate(endDate, resolution) + "}");
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TestPrecedenceQueryParser.java

示例9: assertDateRangeQueryEquals

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
public void assertDateRangeQueryEquals(CommonQueryParserConfiguration cqpC, String field, String startDate, String endDate, 
                                       Date endDateInclusive, DateTools.Resolution resolution) throws Exception {
  assertQueryEquals(cqpC, field, field + ":[" + escapeDateString(startDate) + " TO " + escapeDateString(endDate) + "]",
             "[" + getDate(startDate, resolution) + " TO " + getDate(endDateInclusive, resolution) + "]");
  assertQueryEquals(cqpC, field, field + ":{" + escapeDateString(startDate) + " TO " + escapeDateString(endDate) + "}",
             "{" + getDate(startDate, resolution) + " TO " + getDate(endDate, resolution) + "}");
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:QueryParserTestBase.java

示例10: assertDateRangeQueryEquals

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
public void assertDateRangeQueryEquals(CommonQueryParserConfiguration cqpC, String field, String startDate, String endDate,
                                       Date endDateInclusive, DateTools.Resolution resolution) throws Exception {
  assertQueryEquals(cqpC, field, field + ":[" + escapeDateString(startDate) + " TO " + escapeDateString(endDate) + "]",
      "[" + getDate(startDate, resolution) + " TO " + getDate(endDateInclusive, resolution) + "]");
  assertQueryEquals(cqpC, field, field + ":{" + escapeDateString(startDate) + " TO " + escapeDateString(endDate) + "}",
      "{" + getDate(startDate, resolution) + " TO " + getDate(endDate, resolution) + "}");
}
 
开发者ID:tballison,项目名称:lucene-addons,代码行数:8,代码来源:QueryParserTestBase.java

示例11: getDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/** for testing DateTools support */
private String getDate(String s, DateTools.Resolution resolution)
    throws Exception {
  // we use the default Locale since LuceneTestCase randomizes it
  DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
  return getDate(df.parse(s), resolution);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:8,代码来源:TestQPHelper.java

示例12: getDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/** for testing DateTools support */
private String getDate(Date d, DateTools.Resolution resolution) {
  return DateTools.dateToString(d, resolution);
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:TestQPHelper.java

示例13: getDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/** for testing DateTools support */
private String getDate(String s, DateTools.Resolution resolution) throws Exception {
  // we use the default Locale since LuceneTestCase randomizes it
  DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
  return getDate(df.parse(s), resolution);
}
 
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:TestPrecedenceQueryParser.java

示例14: getDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/** for testing DateTools support */
private String getDate(String s, DateTools.Resolution resolution) throws Exception {
  // we use the default Locale since LuceneTestCase randomizes it
  DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
  return getDate(df.parse(s), resolution);      
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:7,代码来源:QueryParserTestBase.java

示例15: getDate

import org.apache.lucene.document.DateTools; //导入方法依赖的package包/类
/** for testing DateTools support */
private String getDate(String s, DateTools.Resolution resolution) throws Exception {
	// we use the default Locale since LuceneTestCase randomizes it
	DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
	return getDate(df.parse(s), resolution);
}
 
开发者ID:easynet-cn,项目名称:resource-query-parser,代码行数:7,代码来源:QueryParserTestBase.java


注:本文中的org.apache.lucene.document.DateTools.Resolution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。