Skip to content

Commit d885872

Browse files
committed
Fix test
Signed-off-by: Rishabh Maurya <rishabhmaurya05@gmail.com>
1 parent faaae0e commit d885872

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

server/src/main/java/org/opensearch/index/mapper/DerivedField.java

+20
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.opensearch.script.Script;
1919

2020
import java.io.IOException;
21+
import java.util.Objects;
2122

2223
/**
2324
* DerivedField representation: expects a name, type and script.
@@ -69,4 +70,23 @@ public Script getScript() {
6970
return script;
7071
}
7172

73+
@Override
74+
public int hashCode() {
75+
return Objects.hash(name, type, script);
76+
}
77+
78+
@Override
79+
public boolean equals(Object obj) {
80+
if (obj == null) {
81+
return false;
82+
}
83+
if (getClass() != obj.getClass()) {
84+
return false;
85+
}
86+
DerivedField other = (DerivedField) obj;
87+
return Objects.equals(name, other.name)
88+
&& Objects.equals(type, other.type)
89+
&& Objects.equals(script, other.script);
90+
}
91+
7292
}

server/src/main/java/org/opensearch/index/mapper/DerivedFieldMapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private static DerivedFieldMapper toType(FieldMapper in) {
3939
*/
4040
public static class Builder extends ParametrizedFieldMapper.Builder {
4141
// TODO: The type of parameter may change here if the actual underlying FieldType object is needed
42-
private final Parameter<String> type = Parameter.stringParam("type", false, m -> toType(m).type, "keyword");
42+
private final Parameter<String> type = Parameter.stringParam("type", false, m -> toType(m).type, "");
4343

4444
private final Parameter<Script> script = new Parameter<>(
4545
"script",

0 commit comments

Comments
 (0)