本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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());
}
示例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());
}