lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jefferyyuan <yuanyun...@gmail.com>
Subject Re: How to modify Solr StatsComponent to support stats.query
Date Thu, 27 Dec 2012 02:18:54 GMT
Found the way to do this:

I changed code of
org.apache.solr.handler.component.SimpleStats.getStatsFields() like below:
String[] queriesStr = params.getFieldParams(f, "stats.query");
if (queriesStr != null && queriesStr.length > 0) {
	for (String queryStr : queriesStr) {
		QParser qparser = QParser.getParser(queriesStr, "lucene", req);
		SolrQueryParser parser = new SolrQueryParser(qparser, req
			.getSchema().getDefaultSearchFieldName());
		Query query = parser.parse(queriesStr);
		
		DocSet docSet = searcher.getDocSet(query);
		DocSet interSection = docs.intersection(docSet);
		NamedList<?> stv = (NamedList<?>) uif.getStats(searcher,docs,
facets).getStatsValues();
	}
}



--
View this message in context: http://lucene.472066.n3.nabble.com/How-to-modify-Solr-StatsComponent-to-support-stats-query-tp4028991p4029244.html
Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message