use of com.yelp.nrtsearch.server.grpc.PluginRescorer in project nrtsearch by Yelp.
the class SearchRequestProcessor method getRescorers.
/**
* Parses rescorers defined in this search request.
*/
private static List<RescoreTask> getRescorers(IndexState indexState, IndexSearcher searcher, SearchRequest searchRequest) throws IOException {
List<RescoreTask> rescorers = new ArrayList<>();
for (int i = 0; i < searchRequest.getRescorersList().size(); ++i) {
com.yelp.nrtsearch.server.grpc.Rescorer rescorer = searchRequest.getRescorers(i);
String rescorerName = rescorer.getName();
RescoreOperation thisRescoreOperation;
if (rescorer.hasQueryRescorer()) {
QueryRescorer queryRescorer = rescorer.getQueryRescorer();
Query query = QUERY_NODE_MAPPER.getQuery(queryRescorer.getRescoreQuery(), indexState);
query = searcher.rewrite(query);
thisRescoreOperation = QueryRescore.newBuilder().setQuery(query).setQueryWeight(queryRescorer.getQueryWeight()).setRescoreQueryWeight(queryRescorer.getRescoreQueryWeight()).build();
} else if (rescorer.hasPluginRescorer()) {
PluginRescorer plugin = rescorer.getPluginRescorer();
thisRescoreOperation = RescorerCreator.getInstance().createRescorer(plugin);
} else {
throw new IllegalArgumentException("Rescorer should define either QueryRescorer or PluginRescorer");
}
rescorers.add(RescoreTask.newBuilder().setRescoreOperation(thisRescoreOperation).setWindowSize(rescorer.getWindowSize()).setName(rescorerName != null && !rescorerName.equals("") ? rescorerName : String.format("rescorer_%d", i)).build());
}
return rescorers;
}
Aggregations