Make RankEvalRequestTests work with transport client

This commit is contained in:
Christoph Büscher 2016-08-05 13:48:46 +02:00
parent 795017ddfa
commit 8856565b89
5 changed files with 20 additions and 15 deletions

View File

@ -51,12 +51,8 @@ public class RankEvalResponse extends ActionResponse implements ToXContent {
public RankEvalResponse() { public RankEvalResponse() {
} }
@SuppressWarnings("unchecked")
public RankEvalResponse(StreamInput in) throws IOException { public RankEvalResponse(StreamInput in) throws IOException {
super.readFrom(in); this.readFrom(in);
this.specId = in.readString();
this.qualityLevel = in.readDouble();
this.unknownDocs = (Map<String, Collection<RatedDocumentKey>>) in.readGenericValue();
} }
public RankEvalResponse(String specId, double qualityLevel, Map<String, Collection<RatedDocumentKey>> unknownDocs) { public RankEvalResponse(String specId, double qualityLevel, Map<String, Collection<RatedDocumentKey>> unknownDocs) {
@ -65,7 +61,8 @@ public class RankEvalResponse extends ActionResponse implements ToXContent {
this.unknownDocs = unknownDocs; this.unknownDocs = unknownDocs;
} }
public String getSpecId() {
public Object getSpecId() {
return specId; return specId;
} }
@ -79,17 +76,26 @@ public class RankEvalResponse extends ActionResponse implements ToXContent {
@Override @Override
public String toString() { public String toString() {
return "RankEvalResult, ID :[" + specId + "], quality: " + qualityLevel + ", unknown docs: " + unknownDocs; return "RankEvalResponse, ID :[" + specId + "], quality: " + qualityLevel + ", unknown docs: " + unknownDocs;
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeString(specId); out.writeOptionalString(specId);
out.writeDouble(qualityLevel); out.writeOptionalDouble(qualityLevel);
out.writeGenericValue(getUnknownDocs()); out.writeGenericValue(getUnknownDocs());
} }
@Override
@SuppressWarnings("unchecked")
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
this.specId = in.readOptionalString();
this.qualityLevel = in.readOptionalDouble();
this.unknownDocs = (Map<String, Collection<String>>) in.readGenericValue();
}
@Override @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject("rank_eval"); builder.startObject("rank_eval");
@ -105,5 +111,4 @@ public class RankEvalResponse extends ActionResponse implements ToXContent {
builder.endObject(); builder.endObject();
return builder; return builder;
} }
} }

View File

@ -59,7 +59,7 @@ public class RankEvalSpec implements Writeable {
for (int i = 0; i < specSize; i++) { for (int i = 0; i < specSize; i++) {
specifications.add(new QuerySpec(in)); specifications.add(new QuerySpec(in));
} }
eval = in.readNamedWriteable(RankedListQualityMetric.class); // TODO add to registry eval = in.readNamedWriteable(RankedListQualityMetric.class);
taskId = in.readString(); taskId = in.readString();
} }

View File

@ -41,8 +41,7 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, transportClientRatio = 0.0) @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE)
// NORELEASE need to fix transport client use case
public class RankEvalRequestTests extends ESIntegTestCase { public class RankEvalRequestTests extends ESIntegTestCase {
@Override @Override
protected Collection<Class<? extends Plugin>> transportClientPlugins() { protected Collection<Class<? extends Plugin>> transportClientPlugins() {

View File

@ -20,6 +20,7 @@
package org.elasticsearch.test; package org.elasticsearch.test;
import com.carrotsearch.hppc.ObjectArrayList; import com.carrotsearch.hppc.ObjectArrayList;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;