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


Java NumericUtils.longToPrefixCoded方法代码示例

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


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

示例1: normalizeFieldValue

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
public String normalizeFieldValue(String field, Object value) {
  if (NumberUtils.isNumber(value.toString())) {
    Number n = NumberUtils.createNumber(value.toString());
    if (n instanceof Integer)
      return NumericUtils.intToPrefixCoded((Integer) n);
    else if (n instanceof Long)
      return NumericUtils.longToPrefixCoded((Long) n);
    else if (n instanceof Float)
      return NumericUtils.floatToPrefixCoded((Float) n);
    else if (n instanceof Double)
      return NumericUtils.doubleToPrefixCoded((Double) n);
    else
      throw new IllegalArgumentException("Unhandled numeric type: " + n.getClass());
  } else {
    throw new IllegalArgumentException("Value is not a number: " + value);
  }
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:18,代码来源:NumberNormalizer.java

示例2: getCollectionFilters

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
 * Set up the filters for collections - this is for searching within collections.
 * 
 * @param collection - to search within
 * @return - created filter
 * @throws ParseException
 */
private List<Filter> getCollectionFilters(InstitutionalCollection collection) throws ParseException
{
	List<Filter> filters = new LinkedList<Filter>();
	
       //isolate the collection root
	Term t = new Term("collection_root_id", NumericUtils.longToPrefixCoded(collection.getTreeRoot().getId()));
	Query subQuery = new TermQuery( t );
	filters.add(new QueryWrapperFilter(subQuery));
	
	
	//isolate the range of children
	subQuery = NumericRangeQuery.newLongRange("collection_left_value", collection.getLeftValue(), collection.getRightValue(), true, true);
	filters.add(new QueryWrapperFilter(subQuery));
    return filters;
}
 
开发者ID:nate-rcl,项目名称:irplus,代码行数:23,代码来源:DefaultInstitutionalItemSearchService.java

示例3: makeValueToQuery

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
 * Makes the value to query.
 * <br/>The value to query is derived from NumericUtils.longToPrefixCoded(timestamp.getTime().
 * @param value to input query value
 * @param isLowerBoundary true if this is a lower boundary of a range query
 * @param isUpperBoundary true if this is a upper boundary of a range query
 * @return the value to query
 * @throws DiscoveryException if the supplied value cannot be converted
 */
@Override
protected String makeValueToQuery(String value, 
                                  boolean isLowerBoundary,
                                  boolean isUpperBoundary) 
  throws DiscoveryException {
  try {
    PropertyValueType valueType = PropertyValueType.TIMESTAMP;
    Timestamp tsValue = (Timestamp)valueType.evaluate(
        value,isLowerBoundary,isUpperBoundary);
    if (tsValue == null) return null;
    
    if (isLowerBoundary) {
      LOGGER.finer("Lower boundary timestamp to query: "+tsValue);
    } else if (isUpperBoundary) {
      LOGGER.finer("Upper boundary timestamp to query: "+tsValue);
    } else {
      LOGGER.finer("Timestamp to query: "+tsValue);
    }
    
    return NumericUtils.longToPrefixCoded(tsValue.getTime());
  } catch (IllegalArgumentException e) {
    throw new DiscoveryException("Invalid date: "+value);
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:34,代码来源:TimestampField.java

示例4: term

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef term(Double value) {
    long longValue = NumericUtils.doubleToSortableLong(value);
    BytesRefBuilder bytesRef = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(longValue, 0, bytesRef);
    return bytesRef.get();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:TermBuilder.java

示例5: indexedValueForSearch

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef indexedValueForSearch(Object value) {
    long longValue = NumericUtils.doubleToSortableLong(parseDoubleValue(value));
    BytesRefBuilder bytesRef = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(longValue, 0, bytesRef);   // 0 because of exact match
    return bytesRef.get();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:DoubleFieldMapper.java

示例6: toBytesRefs

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
 * Converts a list of long value to their bytes ref representation as performed by
 * {@link org.apache.lucene.analysis.NumericTokenStream}
 */
private BytesRef[] toBytesRefs(long[] values) {
  BytesRef[] bytesRefs = new BytesRef[values.length];
  for (int i = 0; i < values.length; i++) {
    BytesRefBuilder b = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(values[i], 0, b);
    bytesRefs[i] = b.toBytesRef();
  }
  return bytesRefs;
}
 
开发者ID:sirensolutions,项目名称:siren-join,代码行数:14,代码来源:TermsEnumTermsQueryTest.java

示例7: makeValueToQuery

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
 * Makes the value to query.
 * <br/>The value to query is derived from NumericUtils.longToPrefixCoded().
 * @param value to input query value
 * @param isLowerBoundary true if this is a lower boundary of a range query
 * @param isUpperBoundary true if this is a upper boundary of a range query
 * @return the value to query
 * @throws DiscoveryException if the supplied value cannot be converted
 */
@Override
protected String makeValueToQuery(String value, 
                                  boolean isLowerBoundary,
                                  boolean isUpperBoundary) 
  throws DiscoveryException {
  try {
    PropertyValueType valueType = PropertyValueType.LONG;
    Long lValue = (Long)valueType.evaluate(value);
    return NumericUtils.longToPrefixCoded(lValue);
  } catch (NumberFormatException e) {
    throw new DiscoveryException("Invalid Long: "+value);
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:23,代码来源:LongField.java

示例8: valueForSearch

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
private BytesRef valueForSearch(Object value) {
    if (value == null) return null;
    BytesRefBuilder bytesRef = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match
    return bytesRef.get();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:QueryBuilderHelper.java

示例9: indexedValueForSearch

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef indexedValueForSearch(Object value) {
    BytesRefBuilder bytesRef = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match
    return bytesRef.get();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:IpFieldMapper.java

示例10: indexedValueForSearch

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef indexedValueForSearch(Object value) {
    BytesRefBuilder bytesRef = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(parseLongValue(value), 0, bytesRef);  // 0 because of exact match
    return bytesRef.get();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:LongFieldMapper.java

示例11: next

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef next() {
  BytesRefBuilder b = new BytesRefBuilder();
  NumericUtils.longToPrefixCoded((int) values.valueAt(this.count++), 0, b);
  return b.toBytesRef();
}
 
开发者ID:sirensolutions,项目名称:siren-join,代码行数:7,代码来源:BytesRefTermStream.java

示例12: getLongTerm

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
public static Term getLongTerm(String field, long longValue)
{
    BytesRefBuilder bytesBuilder = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(longValue, 0, bytesBuilder);
    return new Term(field, bytesBuilder.get());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:7,代码来源:AlfrescoSolrDataModel.java

示例13: moneyToString

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
 * 将money*1000,转换成long,再转换成string。
 * 
 * @param money
 * @return
 * @see NumberTools#longToString(long)
 */
public static String moneyToString(BigDecimal money) {
	Assert.notNull(money);
	return NumericUtils.longToPrefixCoded(money.multiply(MULTIPLE)
			.longValue());
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:13,代码来源:MoneyTools.java


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