|
@@ -19,10 +19,12 @@
|
|
|
|
|
|
package org.elasticsearch.index.rankeval;
|
|
package org.elasticsearch.index.rankeval;
|
|
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
import org.elasticsearch.action.ActionRequest;
|
|
import org.elasticsearch.action.ActionRequest;
|
|
import org.elasticsearch.action.ActionRequestValidationException;
|
|
import org.elasticsearch.action.ActionRequestValidationException;
|
|
import org.elasticsearch.action.IndicesRequest;
|
|
import org.elasticsearch.action.IndicesRequest;
|
|
import org.elasticsearch.action.search.SearchRequest;
|
|
import org.elasticsearch.action.search.SearchRequest;
|
|
|
|
+import org.elasticsearch.action.search.SearchType;
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
import org.elasticsearch.common.Strings;
|
|
import org.elasticsearch.common.Strings;
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
@@ -42,6 +44,8 @@ public class RankEvalRequest extends ActionRequest implements IndicesRequest.Rep
|
|
private IndicesOptions indicesOptions = SearchRequest.DEFAULT_INDICES_OPTIONS;
|
|
private IndicesOptions indicesOptions = SearchRequest.DEFAULT_INDICES_OPTIONS;
|
|
private String[] indices = Strings.EMPTY_ARRAY;
|
|
private String[] indices = Strings.EMPTY_ARRAY;
|
|
|
|
|
|
|
|
+ private SearchType searchType = SearchType.DEFAULT;
|
|
|
|
+
|
|
public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) {
|
|
public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) {
|
|
this.rankingEvaluationSpec = Objects.requireNonNull(rankingEvaluationSpec, "ranking evaluation specification must not be null");
|
|
this.rankingEvaluationSpec = Objects.requireNonNull(rankingEvaluationSpec, "ranking evaluation specification must not be null");
|
|
indices(indices);
|
|
indices(indices);
|
|
@@ -52,6 +56,9 @@ public class RankEvalRequest extends ActionRequest implements IndicesRequest.Rep
|
|
rankingEvaluationSpec = new RankEvalSpec(in);
|
|
rankingEvaluationSpec = new RankEvalSpec(in);
|
|
indices = in.readStringArray();
|
|
indices = in.readStringArray();
|
|
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
|
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
|
|
|
|
+ searchType = SearchType.fromId(in.readByte());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
RankEvalRequest() {
|
|
RankEvalRequest() {
|
|
@@ -111,12 +118,29 @@ public class RankEvalRequest extends ActionRequest implements IndicesRequest.Rep
|
|
this.indicesOptions = Objects.requireNonNull(indicesOptions, "indicesOptions must not be null");
|
|
this.indicesOptions = Objects.requireNonNull(indicesOptions, "indicesOptions must not be null");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The search type to execute, defaults to {@link SearchType#DEFAULT}.
|
|
|
|
+ */
|
|
|
|
+ public void searchType(SearchType searchType) {
|
|
|
|
+ this.searchType = Objects.requireNonNull(searchType, "searchType must not be null");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The type of search to execute.
|
|
|
|
+ */
|
|
|
|
+ public SearchType searchType() {
|
|
|
|
+ return searchType;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
super.writeTo(out);
|
|
super.writeTo(out);
|
|
rankingEvaluationSpec.writeTo(out);
|
|
rankingEvaluationSpec.writeTo(out);
|
|
out.writeStringArray(indices);
|
|
out.writeStringArray(indices);
|
|
indicesOptions.writeIndicesOptions(out);
|
|
indicesOptions.writeIndicesOptions(out);
|
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
|
|
|
|
+ out.writeByte(searchType.id());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -130,11 +154,12 @@ public class RankEvalRequest extends ActionRequest implements IndicesRequest.Rep
|
|
RankEvalRequest that = (RankEvalRequest) o;
|
|
RankEvalRequest that = (RankEvalRequest) o;
|
|
return Objects.equals(indicesOptions, that.indicesOptions) &&
|
|
return Objects.equals(indicesOptions, that.indicesOptions) &&
|
|
Arrays.equals(indices, that.indices) &&
|
|
Arrays.equals(indices, that.indices) &&
|
|
- Objects.equals(rankingEvaluationSpec, that.rankingEvaluationSpec);
|
|
|
|
|
|
+ Objects.equals(rankingEvaluationSpec, that.rankingEvaluationSpec) &&
|
|
|
|
+ Objects.equals(searchType, that.searchType);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int hashCode() {
|
|
public int hashCode() {
|
|
- return Objects.hash(indicesOptions, Arrays.hashCode(indices), rankingEvaluationSpec);
|
|
|
|
|
|
+ return Objects.hash(indicesOptions, Arrays.hashCode(indices), rankingEvaluationSpec, searchType);
|
|
}
|
|
}
|
|
}
|
|
}
|