|
35 | 35 | import java.util.List; |
36 | 36 | import java.util.Locale; |
37 | 37 | import java.util.Map; |
| 38 | +import java.util.Objects; |
38 | 39 |
|
39 | 40 | import static org.elasticsearch.action.ValidateActions.addValidationError; |
40 | 41 | import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg; |
41 | 42 | import static org.elasticsearch.xpack.rank.RankRRFFeatures.LINEAR_RETRIEVER_SUPPORTED; |
42 | 43 | import static org.elasticsearch.xpack.rank.linear.LinearRetrieverComponent.DEFAULT_WEIGHT; |
43 | 44 |
|
44 | | -// TODO: Add toEquals method |
45 | | - |
46 | 45 | /** |
47 | 46 | * The {@code LinearRetrieverBuilder} supports the combination of different retrievers through a weighted linear combination. |
48 | 47 | * For example, assume that we have retrievers r1 and r2, the final score of the {@code LinearRetrieverBuilder} is defined as |
@@ -368,4 +367,20 @@ public void doToXContent(XContentBuilder builder, Params params) throws IOExcept |
368 | 367 |
|
369 | 368 | builder.field(RANK_WINDOW_SIZE_FIELD.getPreferredName(), rankWindowSize); |
370 | 369 | } |
| 370 | + |
| 371 | + @Override |
| 372 | + public boolean doEquals(Object o) { |
| 373 | + LinearRetrieverBuilder that = (LinearRetrieverBuilder) o; |
| 374 | + return super.doEquals(o) |
| 375 | + && Arrays.equals(weights, that.weights) |
| 376 | + && Arrays.equals(normalizers, that.normalizers) |
| 377 | + && Objects.equals(fields, that.fields) |
| 378 | + && Objects.equals(query, that.query) |
| 379 | + && Objects.equals(normalizer, that.normalizer); |
| 380 | + } |
| 381 | + |
| 382 | + @Override |
| 383 | + public int doHashCode() { |
| 384 | + return Objects.hash(super.doHashCode(), Arrays.hashCode(weights), Arrays.hashCode(normalizers), fields, query, normalizer); |
| 385 | + } |
371 | 386 | } |
0 commit comments