本文整理汇总了Java中org.apache.lucene.index.AtomicReader.fields方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicReader.fields方法的具体用法?Java AtomicReader.fields怎么用?Java AtomicReader.fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.index.AtomicReader
的用法示例。
在下文中一共展示了AtomicReader.fields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: split
import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
FixedBitSet[] split(AtomicReaderContext readerContext) throws IOException {
AtomicReader reader = readerContext.reader();
FixedBitSet[] docSets = new FixedBitSet[numPieces];
for (int i=0; i<docSets.length; i++) {
docSets[i] = new FixedBitSet(reader.maxDoc());
}
Bits liveDocs = reader.getLiveDocs();
Fields fields = reader.fields();
Terms terms = fields==null ? null : fields.terms(field.getName());
TermsEnum termsEnum = terms==null ? null : terms.iterator(null);
if (termsEnum == null) return docSets;
BytesRef term = null;
DocsEnum docsEnum = null;
CharsRef idRef = new CharsRef();
for (;;) {
term = termsEnum.next();
if (term == null) break;
// figure out the hash for the term
// FUTURE: if conversion to strings costs too much, we could
// specialize and use the hash function that can work over bytes.
field.getType().indexedToReadable(term, idRef);
String idString = idRef.toString();
if (splitKey != null) {
// todo have composite routers support these kind of things instead
String part1 = getRouteKey(idString);
if (part1 == null)
continue;
if (!splitKey.equals(part1)) {
continue;
}
}
int hash = 0;
if (hashRouter != null) {
hash = hashRouter.sliceHash(idString, null, null, null);
}
docsEnum = termsEnum.docs(liveDocs, docsEnum, DocsEnum.FLAG_NONE);
for (;;) {
int doc = docsEnum.nextDoc();
if (doc == DocIdSetIterator.NO_MORE_DOCS) break;
if (ranges == null) {
docSets[currPartition].set(doc);
currPartition = (currPartition + 1) % numPieces;
} else {
for (int i=0; i<rangesArr.length; i++) { // inner-loop: use array here for extra speed.
if (rangesArr[i].includes(hash)) {
docSets[i].set(doc);
}
}
}
}
}
return docSets;
}
示例2: createTermIterator
import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
private static InputIterator createTermIterator() throws IOException {
final TermFreqIteratorListWrapper inputIterator = new TermFreqIteratorListWrapper();
final List<AtomicReaderContext> leaves = _indexReader.leaves();
for (final AtomicReaderContext readerContext : leaves) {
final AtomicReader reader = readerContext.reader();
final Fields fields = reader.fields();
for (final String field : fields) {
if (field.equals(SEARCH_FIELD_DESCRIPTION) || field.equals(SEARCH_FIELD_TITLE)) {
final Terms terms = fields.terms(field);
final TermsEnum termsEnum = terms.iterator(null);
inputIterator.add(termsEnum);
}
}
}
return inputIterator;
}