當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。