本文整理汇总了Java中org.apache.lucene.util.NumericUtils.intToPrefixCoded方法的典型用法代码示例。如果您正苦于以下问题:Java NumericUtils.intToPrefixCoded方法的具体用法?Java NumericUtils.intToPrefixCoded怎么用?Java NumericUtils.intToPrefixCoded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.NumericUtils
的用法示例。
在下文中一共展示了NumericUtils.intToPrefixCoded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: term
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef term(Float value) {
int intValue = NumericUtils.floatToSortableInt(value);
BytesRefBuilder bytesRef = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(intValue, 0, bytesRef);
return bytesRef.get();
}
示例3: indexedValueForSearch
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef indexedValueForSearch(Object value) {
int intValue = NumericUtils.floatToSortableInt(parseValue(value));
BytesRefBuilder bytesRef = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(intValue, 0, bytesRef); // 0 because of exact match
return bytesRef.get();
}
示例4: updateDocument
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public boolean updateDocument(ShopDTO shopDTO) {
Document document = buildDucument(shopDTO);
BytesRefBuilder bytes = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(shopDTO.getShopid(), 0, bytes);
Term term = new Term(ShopDTO.ShopParam.SHOP_ID, bytes);
boolean ret = LuceneUtil.updateDocument(term, document);
return ret;
}
示例5: deleteDocument
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public boolean deleteDocument(int shopid) {
BytesRefBuilder bytes = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(shopid, 0, bytes);
Term term = new Term(ShopDTO.ShopParam.SHOP_ID, bytes);
boolean ret = LuceneUtil.deleteDocument(term);
return ret;
}
示例6: readableToIndexed
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void readableToIndexed(CharSequence val, BytesRef result) {
final String s = val.toString();
if (s == null)
return;
final Integer intValue = stringValueToIntValue(s);
BytesRefBuilder b = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(intValue, 0, b);
result.copyBytes(b.get());
}
示例7: storedToIndexed
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String storedToIndexed(IndexableField f) {
final Number val = f.numericValue();
if (val == null)
return null;
final BytesRefBuilder bytes = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(val.intValue(), 0, bytes);
return bytes.get().utf8ToString();
}
示例8: newTermQuery
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
protected Query newTermQuery(Term term) {
if (InformationAssetViewFields.SOURCE.toString().equals(term.field())) {
BytesRefBuilder byteRefBuilder = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(Integer.parseInt(term.text()), 0, byteRefBuilder);
TermQuery tq = new TermQuery(new Term(term.field(), byteRefBuilder.get()));
return tq;
}
return super.newTermQuery(term);
}
示例9: getSourceFilterForValue
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
private Query getSourceFilterForValue(String sourceValue) {
Integer intCatalogueSourceValue = Integer.valueOf(sourceValue);
BytesRefBuilder bytes = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(intCatalogueSourceValue, 0, bytes);
TermQuery termFilter = new TermQuery(new Term(InformationAssetViewFields.SOURCE.toString(), bytes.get()));
return termFilter;
}
示例10: readableToIndexed
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void readableToIndexed(CharSequence val, BytesRef result) {
final String s = val.toString();
if (s == null)
return;
final Integer intValue = stringValueToIntValue(s);
NumericUtils.intToPrefixCoded(intValue, 0, result);
}
示例11: storedToIndexed
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String storedToIndexed(IndexableField f) {
final Number val = f.numericValue();
if (val == null)
return null;
final BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
NumericUtils.intToPrefixCoded(val.intValue(), 0, bytes);
return bytes.utf8ToString();
}
示例12: indexedValueForSearch
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef indexedValueForSearch(Object value) {
BytesRefBuilder bytesRef = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match
return bytesRef.get();
}
示例13: indexedValueForSearch
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef indexedValueForSearch(Object value) {
BytesRefBuilder bytesRef = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match
return bytesRef.get();
}
示例14: next
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef next() {
BytesRefBuilder b = new BytesRefBuilder();
NumericUtils.intToPrefixCoded((int) values.valueAt(this.count++), 0, b);
return b.toBytesRef();
}
示例15: intTerm
import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
static Term intTerm(String name, int value) {
BytesRefBuilder builder = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(value, 0, builder);
return new Term(name, builder.get());
}