当前位置: 首页>>代码示例>>Java>>正文


Java AtomicReader.fields方法代码示例

本文整理汇总了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;
}
 
开发者ID:europeana,项目名称:search,代码行数:63,代码来源:SolrIndexSplitter.java

示例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;
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:26,代码来源:FTSearchManager.java


注:本文中的org.apache.lucene.index.AtomicReader.fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。