當前位置: 首頁>>代碼示例>>Java>>正文


Java Collector.collect方法代碼示例

本文整理匯總了Java中org.apache.lucene.search.Collector.collect方法的典型用法代碼示例。如果您正苦於以下問題:Java Collector.collect方法的具體用法?Java Collector.collect怎麽用?Java Collector.collect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.search.Collector的用法示例。


在下文中一共展示了Collector.collect方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: collectHit

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
private void collectHit(Collector collector, Collector[] sidewaysCollectors) throws IOException {
  //if (DEBUG) {
  //  System.out.println("      hit");
  //}

  collector.collect(collectDocID);
  if (drillDownCollector != null) {
    drillDownCollector.collect(collectDocID);
  }

  // TODO: we could "fix" faceting of the sideways counts
  // to do this "union" (of the drill down hits) in the
  // end instead:

  // Tally sideways counts:
  for (int dim=0;dim<sidewaysCollectors.length;dim++) {
    sidewaysCollectors[dim].collect(collectDocID);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:20,代碼來源:DrillSidewaysScorer.java

示例2: score

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
@Override
public boolean score(Collector collector, int max) throws IOException {
  FakeScorer fakeScorer = new FakeScorer();
  collector.setScorer(fakeScorer);
  if (doc == -1) {
    doc = nextDocOutOfOrder();
  }
  while(doc < max) {
    fakeScorer.doc = doc;
    fakeScorer.score = scores[ords[scoreUpto]];
    collector.collect(doc);
    doc = nextDocOutOfOrder();
  }

  return doc != DocsEnum.NO_MORE_DOCS;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:17,代碼來源:TermsIncludingScoreQuery.java

示例3: testNullCollectors

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
@Test
public void testNullCollectors() throws Exception {
  // Tests that the collector rejects all null collectors.
  try {
    MultiCollector.wrap(null, null);
    fail("only null collectors should not be supported");
  } catch (IllegalArgumentException e) {
    // expected
  }

  // Tests that the collector handles some null collectors well. If it
  // doesn't, an NPE would be thrown.
  Collector c = MultiCollector.wrap(new DummyCollector(), null, new DummyCollector());
  assertTrue(c instanceof MultiCollector);
  assertTrue(c.acceptsDocsOutOfOrder());
  c.collect(1);
  c.setNextReader(null);
  c.setScorer(null);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:20,代碼來源:MultiCollectorTest.java

示例4: testCollector

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
@Test
public void testCollector() throws Exception {
  // Tests that the collector delegates calls to input collectors properly.

  // Tests that the collector handles some null collectors well. If it
  // doesn't, an NPE would be thrown.
  DummyCollector[] dcs = new DummyCollector[] { new DummyCollector(), new DummyCollector() };
  Collector c = MultiCollector.wrap(dcs);
  assertTrue(c.acceptsDocsOutOfOrder());
  c.collect(1);
  c.setNextReader(null);
  c.setScorer(null);

  for (DummyCollector dc : dcs) {
    assertTrue(dc.acceptsDocsOutOfOrderCalled);
    assertTrue(dc.collectCalled);
    assertTrue(dc.setNextReaderCalled);
    assertTrue(dc.setScorerCalled);
  }

}
 
開發者ID:europeana,項目名稱:search,代碼行數:22,代碼來源:MultiCollectorTest.java

示例5: collectHit

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
private void collectHit(Collector collector, Collector[] sidewaysCollectors, Collector[] sidewaysCollectors2) throws IOException {
  //if (DEBUG) {
  //  System.out.println("      hit");
  //}

  collector.collect(collectDocID);
  if (drillDownCollector != null) {
    drillDownCollector.collect(collectDocID);
  }

  // TODO: we could "fix" faceting of the sideways counts
  // to do this "union" (of the drill down hits) in the
  // end instead:

  // Tally sideways counts:
  for (int i=0;i<sidewaysCollectors.length;i++) {
    sidewaysCollectors[i].collect(collectDocID);
  }
  for (int i=0;i<sidewaysCollectors2.length;i++) {
    sidewaysCollectors2[i].collect(collectDocID);
  }
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:23,代碼來源:DrillSidewaysScorer.java

示例6: collect

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
public void collect(int docId) throws IOException {
  int doc = docId + docBase;
  int ord = docValues.getOrd(doc);
  if (ord > -1 && groupBits.get(ord) && !collapsedSet.contains(doc)) {
    Collector c = groups.get(ord);
    c.collect(docId);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:9,代碼來源:ExpandComponent.java

示例7: score

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
/**
 * Scores and collects all matching documents.
 * 
 * @param collector
 *            The collector to which all matching documents are passed
 *            through.
 */
@Override
public void score(Collector collector) throws IOException {
	collector.setScorer(this);
	while ((doc = countingSumScorer.nextDoc()) != NO_MORE_DOCS) {
		collector.collect(doc);
	}
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:15,代碼來源:LearnToRankScorer.java

示例8: score

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
@Override
public void score(Collector collector) throws IOException {
  collector.setScorer(this);
  for (int doc = nextDocOutOfOrder(); doc != NO_MORE_DOCS; doc = nextDocOutOfOrder()) {
    collector.collect(doc);
  }
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:8,代碼來源:TermsIncludingScoreQuery.java

示例9: collect

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
@Override
public void collect(int doc) throws IOException {
  for (Collector c : collectors) {
    c.collect(doc);
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:7,代碼來源:MultiCollector.java

示例10: collectNearMiss

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
private void collectNearMiss(Collector sidewaysCollector) throws IOException {
  //if (DEBUG) {
  //  System.out.println("      missingDim=" + dim);
  //}
  sidewaysCollector.collect(collectDocID);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:7,代碼來源:DrillSidewaysScorer.java

示例11: getDocSet

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
/**
 * Returns the set of document ids matching all queries.
 * This method is cache-aware and attempts to retrieve the answer from the cache if possible.
 * If the answer was not cached, it may have been inserted into the cache as a result of this call.
 * This method can handle negative queries.
 * <p>
 * The DocSet returned should <b>not</b> be modified.
 */
public DocSet getDocSet(List<Query> queries) throws IOException {

  if(queries != null) {
    for(Query q : queries) {
      if(q instanceof ScoreFilter) {
        return getDocSetScore(queries);
      }
    }
  }

  ProcessedFilter pf = getProcessedFilter(null, queries);
  if (pf.answer != null) return pf.answer;


  DocSetCollector setCollector = new DocSetCollector(maxDoc()>>6, maxDoc());
  Collector collector = setCollector;
  if (pf.postFilter != null) {
    pf.postFilter.setLastDelegate(collector);
    collector = pf.postFilter;
  }

  for (final AtomicReaderContext leaf : leafContexts) {
    final AtomicReader reader = leaf.reader();
    final Bits liveDocs = reader.getLiveDocs();   // TODO: the filter may already only have liveDocs...
    DocIdSet idSet = null;
    if (pf.filter != null) {
      idSet = pf.filter.getDocIdSet(leaf, liveDocs);
      if (idSet == null) continue;
    }
    DocIdSetIterator idIter = null;
    if (idSet != null) {
      idIter = idSet.iterator();
      if (idIter == null) continue;
    }

    collector.setNextReader(leaf);
    int max = reader.maxDoc();

    if (idIter == null) {
      for (int docid = 0; docid<max; docid++) {
        if (liveDocs != null && !liveDocs.get(docid)) continue;
        collector.collect(docid);
      }
    } else {
      for (int docid = -1; (docid = idIter.advance(docid+1)) < max; ) {
        collector.collect(docid);
      }
    }
  }

  if(collector instanceof DelegatingCollector) {
    ((DelegatingCollector) collector).finish();
  }

  return setCollector.getDocSet();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:65,代碼來源:SolrIndexSearcher.java

示例12: getDocSet

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
/**
 * Returns the set of document ids matching all queries.
 * This method is cache-aware and attempts to retrieve the answer from the cache if possible.
 * If the answer was not cached, it may have been inserted into the cache as a result of this call.
 * This method can handle negative queries.
 * <p>
 * The DocSet returned should <b>not</b> be modified.
 */
public DocSet getDocSet(List<Query> queries) throws IOException {
  ProcessedFilter pf = getProcessedFilter(null, queries);
  if (pf.answer != null) return pf.answer;


  DocSetCollector setCollector = new DocSetCollector(maxDoc()>>6, maxDoc());
  Collector collector = setCollector;
  if (pf.postFilter != null) {
    pf.postFilter.setLastDelegate(collector);
    collector = pf.postFilter;
  }

  for (final AtomicReaderContext leaf : leafContexts) {
    final AtomicReader reader = leaf.reader();
    final Bits liveDocs = reader.getLiveDocs();   // TODO: the filter may already only have liveDocs...
    DocIdSet idSet = null;
    if (pf.filter != null) {
      idSet = pf.filter.getDocIdSet(leaf, liveDocs);
      if (idSet == null) continue;
    }
    DocIdSetIterator idIter = null;
    if (idSet != null) {
      idIter = idSet.iterator();
      if (idIter == null) continue;
    }

    collector.setNextReader(leaf);
    int max = reader.maxDoc();

    if (idIter == null) {
      for (int docid = 0; docid<max; docid++) {
        if (liveDocs != null && !liveDocs.get(docid)) continue;
        collector.collect(docid);
      }
    } else {
      for (int docid = -1; (docid = idIter.advance(docid+1)) < max; ) {
        collector.collect(docid);
      }
    }
  }

  return setCollector.getDocSet();
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:52,代碼來源:SolrIndexSearcher.java

示例13: getDocSet

import org.apache.lucene.search.Collector; //導入方法依賴的package包/類
/**
 * Returns the set of document ids matching all queries. This method is cache-aware and attempts
 * to retrieve the answer from the cache if possible. If the answer was not cached, it may have
 * been inserted into the cache as a result of this call. This method can handle negative
 * queries.
 * <p>
 * The DocSet returned should <b>not</b> be modified.
 */
public DocSet getDocSet(List<Query> queries) throws IOException {
	ProcessedFilter pf = getProcessedFilter(null, queries);
	if(pf.answer != null)
		return pf.answer;

	DocSetCollector setCollector = new DocSetCollector(maxDoc() >> 6, maxDoc());
	Collector collector = setCollector;
	if(pf.postFilter != null) {
		pf.postFilter.setLastDelegate(collector);
		collector = pf.postFilter;
	}

	for(final AtomicReaderContext leaf : leafContexts) {
		final AtomicReader reader = leaf.reader();
		final Bits liveDocs = reader.getLiveDocs(); // TODO: the filter may already only have liveDocs...
		DocIdSet idSet = null;
		if(pf.filter != null) {
			idSet = pf.filter.getDocIdSet(leaf, liveDocs);
			if(idSet == null)
				continue;
		}
		DocIdSetIterator idIter = null;
		if(idSet != null) {
			idIter = idSet.iterator();
			if(idIter == null)
				continue;
		}

		collector.setNextReader(leaf);
		int max = reader.maxDoc();

		if(idIter == null) {
			for(int docid = 0; docid < max; docid++) {
				if(liveDocs != null && !liveDocs.get(docid))
					continue;
				collector.collect(docid);
			}
		} else {
			for(int docid = -1; (docid = idIter.advance(docid + 1)) < max;) {
				collector.collect(docid);
			}
		}
	}

	return setCollector.getDocSet();
}
 
開發者ID:netboynb,項目名稱:search-core,代碼行數:55,代碼來源:SolrIndexSearcher.java


注:本文中的org.apache.lucene.search.Collector.collect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。