void addToDoc(Document doc, String... values){
Preconditions.checkArgument(valueType == String.class);
if (isSorted()) {
Preconditions.checkArgument(values.length < 2, "sorted fields cannot have multiple values");
}
// add distinct elements to doc
final Iterable<String> nonNull = FluentIterable.from(Arrays.asList(values))
.filter(new Predicate<String>() {
@Override
public boolean apply(@Nullable final String input) {
return input != null;
}
});
for (final String value : ImmutableSet.copyOf(nonNull)) {
final String truncatedValue = StringUtils.abbreviate(value, MAX_STRING_LENGTH);
doc.add(new StringField(indexFieldName, truncatedValue, stored ? Store.YES : Store.NO));
}
if (isSorted() && values.length == 1) {
Preconditions.checkArgument(sortedValueType == SearchFieldSorting.FieldType.STRING);
doc.add(new SortedDocValuesField(indexFieldName, new BytesRef(values[0])));
}
}
IndexKey.java 文件源码
java
阅读 34
收藏 0
点赞 0
评论 0
项目:dremio-oss
作者:
评论列表
文章目录