mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Using client instead of TransportSearchAction
This commit is contained in:
parent
bd51c315d6
commit
e71e29b3a0
@ -23,7 +23,6 @@ import org.elasticsearch.action.ActionFuture;
|
|||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.search.SearchRequest;
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.action.search.TransportSearchAction;
|
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.AutoCreateIndex;
|
import org.elasticsearch.action.support.AutoCreateIndex;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
@ -62,6 +61,7 @@ public class TransportRankEvalAction extends HandledTransportAction<RankEvalRequ
|
|||||||
private SearchTransportService searchTransportService;
|
private SearchTransportService searchTransportService;
|
||||||
private ClusterService clusterService;
|
private ClusterService clusterService;
|
||||||
private ActionFilters actionFilters;
|
private ActionFilters actionFilters;
|
||||||
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportRankEvalAction(Settings settings, ThreadPool threadPool, ActionFilters actionFilters,
|
public TransportRankEvalAction(Settings settings, ThreadPool threadPool, ActionFilters actionFilters,
|
||||||
@ -75,6 +75,7 @@ public class TransportRankEvalAction extends HandledTransportAction<RankEvalRequ
|
|||||||
this.searchTransportService = searchTransportService;
|
this.searchTransportService = searchTransportService;
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.actionFilters = actionFilters;
|
this.actionFilters = actionFilters;
|
||||||
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,7 +83,6 @@ public class TransportRankEvalAction extends HandledTransportAction<RankEvalRequ
|
|||||||
RankEvalSpec qualityTask = request.getRankEvalSpec();
|
RankEvalSpec qualityTask = request.getRankEvalSpec();
|
||||||
RankedListQualityMetric metric = qualityTask.getEvaluator();
|
RankedListQualityMetric metric = qualityTask.getEvaluator();
|
||||||
|
|
||||||
double qualitySum = 0;
|
|
||||||
Map<String, Collection<RatedDocumentKey>> unknownDocs = new HashMap<>();
|
Map<String, Collection<RatedDocumentKey>> unknownDocs = new HashMap<>();
|
||||||
Collection<QuerySpec> specifications = qualityTask.getSpecifications();
|
Collection<QuerySpec> specifications = qualityTask.getSpecifications();
|
||||||
Vector<EvalQueryQuality> partialResults = new Vector<>(specifications.size());
|
Vector<EvalQueryQuality> partialResults = new Vector<>(specifications.size());
|
||||||
@ -95,10 +95,8 @@ public class TransportRankEvalAction extends HandledTransportAction<RankEvalRequ
|
|||||||
spec.getTypes().toArray(types);
|
spec.getTypes().toArray(types);
|
||||||
templatedRequest.types(types);
|
templatedRequest.types(types);
|
||||||
|
|
||||||
TransportSearchAction transportSearchAction = new TransportSearchAction(settings, threadPool, searchPhaseController,
|
ActionFuture<SearchResponse> response = client.search(templatedRequest);
|
||||||
transportService, searchTransportService, clusterService, actionFilters, indexNameExpressionResolver);
|
SearchHits hits = response.actionGet().getHits();
|
||||||
ActionFuture<SearchResponse> searchResponse = transportSearchAction.execute(templatedRequest);
|
|
||||||
SearchHits hits = searchResponse.actionGet().getHits();
|
|
||||||
|
|
||||||
EvalQueryQuality queryQuality = metric.evaluate(hits.getHits(), spec.getRatedDocs());
|
EvalQueryQuality queryQuality = metric.evaluate(hits.getHits(), spec.getRatedDocs());
|
||||||
partialResults.addElement(queryQuality);
|
partialResults.addElement(queryQuality);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user