Merge branch 'origin/feature/rank-eval' into feature/rank-eval_index_type_to_id

This commit is contained in:
Isabel Drost-Fromm 2016-08-03 13:50:13 +02:00
commit ac3f2421b1
7 changed files with 13 additions and 0 deletions

View File

@ -128,6 +128,7 @@ public class PrecisionAtN extends RankedListQualityMetric {
return new EvalQueryQuality(precision, unknownDocIds);
}
// TODO add abstraction that also works for other metrics
public enum Rating {
IRRELEVANT, RELEVANT;
}

View File

@ -38,6 +38,7 @@ import java.util.Map;
* Documents of unknown quality - i.e. those that haven't been supplied in the set of annotated documents but have been returned
* by the search are not taken into consideration when computing precision at n - they are ignored.
*
* TODO get rid of either this or RankEvalResult
**/
public class RankEvalResponse extends ActionResponse implements ToXContent {

View File

@ -32,6 +32,7 @@ import java.util.Map;
* for reference. In addition the averaged precision and the ids of all documents returned but not found annotated is returned.
* */
// TODO do we need an extra class for this or it RankEvalResponse enough?
// TODO instead of just returning averages over complete results, think of other statistics, micro avg, macro avg, partial results
public class RankEvalResult implements Writeable {
/**ID of QA specification this result was generated for.*/
private String specId;

View File

@ -54,6 +54,7 @@ public abstract class RankedListQualityMetric implements NamedWriteable {
}
String metricName = parser.currentName();
// TODO maybe switch to using a plugable registry later?
switch (metricName) {
case PrecisionAtN.NAME:
rc = PrecisionAtN.fromXContent(parser, context);

View File

@ -192,6 +192,7 @@ public class RestRankEvalAction extends BaseRestHandler {
QueryParseContext parseContext = new QueryParseContext(queryRegistry, parser, parseFieldMatcher);
if (restContent != null) {
parseRankEvalRequest(rankEvalRequest, request,
// TODO can we get rid of aggregators parsers and suggesters?
new RankEvalContext(parseFieldMatcher, parseContext, aggregators, suggesters));
}
}
@ -224,10 +225,13 @@ public class RestRankEvalAction extends BaseRestHandler {
public static void parseRankEvalRequest(RankEvalRequest rankEvalRequest, RestRequest request, RankEvalContext context)
throws IOException {
List<String> indices = Arrays.asList(Strings.splitStringByCommaToArray(request.param("index")));
List<String> types = Arrays.asList(Strings.splitStringByCommaToArray(request.param("type")));
RankEvalSpec spec = PARSER.parse(context.parser(), context);
for (QuerySpec specification : spec.getSpecifications()) {
specification.setIndices(indices);
specification.setTypes(types);
};
rankEvalRequest.setRankEvalSpec(spec);
}
}

View File

@ -92,6 +92,9 @@ public class TransportRankEvalAction extends HandledTransportAction<RankEvalRequ
String[] indices = new String[spec.getIndices().size()];
spec.getIndices().toArray(indices);
SearchRequest templatedRequest = new SearchRequest(indices, specRequest);
String[] types = new String[spec.getTypes().size()];
spec.getTypes().toArray(types);
templatedRequest.types(types);
TransportSearchAction transportSearchAction = new TransportSearchAction(settings, threadPool, searchPhaseController,
transportService, searchTransportService, clusterService, actionFilters, indexNameExpressionResolver);
@ -103,6 +106,7 @@ public class TransportRankEvalAction extends HandledTransportAction<RankEvalRequ
unknownDocs.put(spec.getSpecId(), intentQuality.getUnknownDocs());
}
RankEvalResponse response = new RankEvalResponse();
// TODO move averaging to actual metric, also add other statistics
RankEvalResult result = new RankEvalResult(qualityTask.getTaskId(), qualitySum / specifications.size(), unknownDocs);
response.setRankEvalResult(result);
listener.onResponse(response);

View File

@ -65,6 +65,7 @@ public class QuerySpecTests extends ESTestCase {
aggsParsers = null;
}
// TODO add some sort of roundtrip testing like we have now for queries?
public void testParseFromXContent() throws IOException {
String querySpecString = " {\n"
+ " \"id\": \"my_qa_query\",\n"