lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adfel70 <adfe...@gmail.com>
Subject How to tell when Collector finishes collect loop?
Date Wed, 03 Jun 2015 13:50:33 GMT
Hi guys, need your help (again):
I have a search handler which need to override solr's scoring. I chose to
implement it with RankQuery API, so when getTopDocsCollector() gets called
it instantiates my TopDocsCollector instance, and every dicId gets its own
score:

public class MyScorerrankQuet extends RankQuery {
	...

	@Override
	public TopDocsCollector getTopDocsCollector(int i,
SolrIndexerSearcher.QueryCommand cmd, IndexSearcher searcher) {
		...
		return new MyCollector(...)
	}
}

public class MyCollector  extends TopDocsCollector{
	//Initialized in constrctor	
	MyScorer scorer;

	public MyCollector(){
		scorer = new MyScorer();
		scorer.start();		//the scorer's API needs to call start() before every
query and close() at the end of the query
	}

	@Override
	public void collect(int id){
		//1. get specific field from the doc using DocValues and calculate score
using my scorer
		//2. add docId and score (ScoreDoc object) into PriorityQueue.
	}
}

My problem is that I cant find a place to call scorer.close(), which need to
be executed when the query ends (after we calculated score for each docID).
I saw the DeligatingCollector has finish() method which is called after
collector is done, but I cannot extend both TopDocsCollector and
DeligatingCollector...





--
View this message in context: http://lucene.472066.n3.nabble.com/How-to-tell-when-Collector-finishes-collect-loop-tp4209447.html
Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message