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


Java DocIdSet类代码示例

本文整理汇总了Java中org.apache.lucene.search.DocIdSet的典型用法代码示例。如果您正苦于以下问题:Java DocIdSet类的具体用法?Java DocIdSet怎么用?Java DocIdSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DocIdSet类属于org.apache.lucene.search包,在下文中一共展示了DocIdSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDocIdSet

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
public DocIdSet getDocIdSet(IndexReader reader) throws IOException
{
	int max = reader.maxDoc();
	OpenBitSet good = new OpenBitSet(max);
	good.set(0, max);
	for( List<Field> values : terms )
	{
		for( Field nv : values )
		{
			Term term = new Term(nv.getField(), nv.getValue());
			TermDocs docs = reader.termDocs(term);
			while( docs.next() )
			{
				good.clear(docs.doc());
			}
			docs.close();
		}
	}
	return good;
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:MustNotFilter.java

示例2: scorer

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
    DocIdSet childrenDocSet = childrenFilter.getDocIdSet(context, null);
    // we forcefully apply live docs here so that deleted children don't give matching parents
    childrenDocSet = BitsFilteredDocIdSet.wrap(childrenDocSet, context.reader().getLiveDocs());
    if (Lucene.isEmpty(childrenDocSet)) {
        return null;
    }
    final DocIdSetIterator childIterator = childrenDocSet.iterator();
    if (childIterator == null) {
        return null;
    }
    SortedDocValues bytesValues = globalIfd.load(context).getOrdinalsValues(parentType);
    if (bytesValues == null) {
        return null;
    }

    return new ChildScorer(this, parentIdxs, scores, childIterator, bytesValues);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:ParentQuery.java

示例3: scorer

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
    DocIdSet childrenDocIdSet = childrenFilter.getDocIdSet(context, null);
    if (Lucene.isEmpty(childrenDocIdSet)) {
        return null;
    }

    SortedDocValues globalValues = globalIfd.load(context).getOrdinalsValues(parentType);
    if (globalValues != null) {
        // we forcefully apply live docs here so that deleted children don't give matching parents
        childrenDocIdSet = BitsFilteredDocIdSet.wrap(childrenDocIdSet, context.reader().getLiveDocs());
        DocIdSetIterator innerIterator = childrenDocIdSet.iterator();
        if (innerIterator != null) {
            ChildrenDocIdIterator childrenDocIdIterator = new ChildrenDocIdIterator(
                    innerIterator, parentOrds, globalValues
            );
            return ConstantScorer.create(childrenDocIdIterator, this, queryWeight);
        }
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:ParentConstantScoreQuery.java

示例4: getDocIdSet

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, final Bits acceptDocs) throws IOException {
  Terms terms = context.reader().terms(term.field());
  if (terms == null) {
    return null;
  }

  final TermsEnum termsEnum = terms.iterator(null);
  if (!termsEnum.seekExact(term.bytes())) {
    return null;
  }
  return new DocIdSet() {
    @Override
    public DocIdSetIterator iterator() throws IOException {
      return termsEnum.docs(acceptDocs, null, DocsEnum.FLAG_NONE);
    }

  };
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:TermFilter.java

示例5: createDocs

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
/**
 * Creates a {@link Docs} to record hits. The default uses {@link FixedBitSet}
 * to record hits and you can override to e.g. record the docs in your own
 * {@link DocIdSet}.
 */
protected Docs createDocs(final int maxDoc) {
  return new Docs() {
    private final FixedBitSet bits = new FixedBitSet(maxDoc);
    
    @Override
    public void addDoc(int docId) throws IOException {
      bits.set(docId);
    }
    
    @Override
    public DocIdSet getDocIdSet() {
      return bits;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:FacetsCollector.java

示例6: docIdSetToCache

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
protected DocIdSet docIdSetToCache(DocIdSet docIdSet, AtomicReader reader)
    throws IOException {
  if (docIdSet == null) {
    return EMPTY;
  } else if (docIdSet instanceof FixedBitSet) {
    // this is different from CachingWrapperFilter: even when the DocIdSet is
    // cacheable, we convert it to a FixedBitSet since we require all the
    // cached filters to be FixedBitSets
    return docIdSet;
  } else {
    final DocIdSetIterator it = docIdSet.iterator();
    if (it == null) {
      return EMPTY;
    } else {
      final FixedBitSet copy = new FixedBitSet(reader.maxDoc());
      copy.or(it);
      return copy;
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:FixedBitSetCachingWrapperFilter.java

示例7: scorer

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
public Scorer scorer(AtomicReaderContext context, Bits acceptDocs) throws IOException {

	if (filter == null) {
		boolean debug = rb != null && rb.isDebug();
		long start = System.currentTimeMillis();
		resultSet = getDocSet();
		long delta = System.currentTimeMillis()-start;
		if (debug) {
			System.out.println("Graph Traverse took : " + delta + " ms.");
		}

		filter = resultSet.getTopFilter();
	}
	// TODO: understand this comment.
	// Although this set only includes live docs, other filters can be pushed down to queries.
	DocIdSet readerSet = filter.getDocIdSet(context, acceptDocs);
	// create a scrorer on the result set, if results from right query are empty, use empty iterator.
	return new GraphScorer(this, readerSet == null ? DocIdSetIterator.empty() : readerSet.iterator(), getBoost());
}
 
开发者ID:kwatters,项目名称:solrgraph,代码行数:21,代码来源:GraphQuery.java

示例8: getNullDISIFilter

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
private Filter getNullDISIFilter() {
  return new Filter() {
    @Override
    public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) {
      return new DocIdSet() {
        @Override
        public DocIdSetIterator iterator() {
          return null;
        }
        
        @Override
        public boolean isCacheable() {
          return true;
        }
      };
    }
  };
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:BooleanFilterTest.java

示例9: getComplementSet

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
/**
 * Create a complement of the input set. The returned {@link ScoredDocIDs}
 * does not contain any scores, which makes sense given that the complementing
 * documents were not scored.
 * 
 * Note: the complement set does NOT contain doc ids which are noted as deleted by the given reader
 * 
 * @param docids to be complemented.
 * @param reader holding the number of documents & information about deletions.
 */
public final static ScoredDocIDs getComplementSet(final ScoredDocIDs docids, final IndexReader reader)
    throws IOException {
  final int maxDoc = reader.maxDoc();

  DocIdSet docIdSet = docids.getDocIDs();
  final FixedBitSet complement;
  if (docIdSet instanceof FixedBitSet) {
    // That is the most common case, if ScoredDocIdsCollector was used.
    complement = ((FixedBitSet) docIdSet).clone();
  } else {
    complement = new FixedBitSet(maxDoc);
    DocIdSetIterator iter = docIdSet.iterator();
    int doc;
    while ((doc = iter.nextDoc()) < maxDoc) {
      complement.set(doc);
    }
  }
  complement.flip(0, maxDoc);
  clearDeleted(reader, complement);

  return createScoredDocIds(complement, maxDoc);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:33,代码来源:ScoredDocIdsUtils.java

示例10: getFullyEmptyDocIdSet

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
public static DocIdSet getFullyEmptyDocIdSet(int maxDoc) {
  Bits bits = getFullyEmptyBits(maxDoc);
  return new DocIdSet() {
    @Override
    public DocIdSetIterator iterator() throws IOException {
      return getFullyEmptyDocIdSetIterator(maxDoc);
    }

    @Override
    public Bits bits() throws IOException {
      return bits;
    }

    @Override
    public boolean isCacheable() {
      return true;
    }
  };
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:20,代码来源:BitSetDocumentVisibilityFilterCacheStrategy.java

示例11: docIdSetToCache

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
private DocIdSet docIdSetToCache(DocIdSet docIdSet, AtomicReader reader, String segmentName, Directory directory)
    throws IOException {
  if (docIdSet == null) {
    // this is better than returning null, as the nonnull result can be cached
    return DocIdSet.EMPTY_DOCIDSET;
  } else if (docIdSet.isCacheable()) {
    return docIdSet;
  } else {
    final DocIdSetIterator it = docIdSet.iterator();
    // null is allowed to be returned by iterator(),
    // in this case we wrap with the empty set,
    // which is cacheable.
    if (it == null) {
      return DocIdSet.EMPTY_DOCIDSET;
    } else {
      final IndexFileBitSet bits = new IndexFileBitSet(reader.maxDoc(), _id, segmentName, directory);
      if (!bits.exists()) {
        bits.create(it);
      }
      bits.load();
      return bits;
    }
  }
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:25,代码来源:FilterCache.java

示例12: docIdSetToCache

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
protected DocIdSet docIdSetToCache(DocIdSet docIdSet, AtomicReader reader)
    throws IOException {
  if (docIdSet == null) {
    return EMPTY_DOCIDSET;
  } else if (docIdSet instanceof FixedBitSet) {
    // this is different from CachingWrapperFilter: even when the DocIdSet is
    // cacheable, we convert it to a FixedBitSet since we require all the
    // cached filters to be FixedBitSets
    return docIdSet;
  } else {
    final DocIdSetIterator it = docIdSet.iterator();
    if (it == null) {
      return EMPTY_DOCIDSET;
    } else {
      final FixedBitSet copy = new FixedBitSet(reader.maxDoc());
      copy.or(it);
      return copy;
    }
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:FixedBitSetCachingWrapperFilter.java

示例13: createWeight

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
    return new ConstantScoreWeight(this) {
        @Override
        public Scorer scorer(LeafReaderContext context) throws IOException {
            final DocIdSet disi = build(context.reader());
            final DocIdSetIterator leafIt = disi.iterator();
            return new ConstantScoreScorer(this, score(), leafIt);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:TermsSliceQuery.java

示例14: build

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
/**
 * Returns a DocIdSet per segments containing the matching docs for the specified slice.
 */
private DocIdSet build(LeafReader reader) throws IOException {
    final DocIdSetBuilder builder = new DocIdSetBuilder(reader.maxDoc());
    final Terms terms = reader.terms(getField());
    final TermsEnum te = terms.iterator();
    PostingsEnum docsEnum = null;
    for (BytesRef term = te.next(); term != null; term = te.next()) {
        int hashCode = term.hashCode();
        if (contains(hashCode)) {
            docsEnum = te.postings(docsEnum, PostingsEnum.NONE);
            builder.add(docsEnum);
        }
    }
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:TermsSliceQuery.java

示例15: getDocIdSet

import org.apache.lucene.search.DocIdSet; //导入依赖的package包/类
@Override
public DocIdSet getDocIdSet(IndexReader reader) throws IOException
{
	int max = reader.maxDoc();
	OpenBitSet good = new OpenBitSet(max);
	Institution institution = CurrentInstitution.get();
	Term term = new Term(FreeTextQuery.FIELD_INSTITUTION, Long.toString(institution.getUniqueId()));
	TermDocs docs = reader.termDocs(term);
	while( docs.next() )
	{
		good.set(docs.doc());
	}
	docs.close();
	return good;
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:InstitutionFilter.java


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