Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Maurya <[email protected]>
  • Loading branch information
rishabhmaurya committed Apr 4, 2024
1 parent faaae0e commit d885872
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions server/src/main/java/org/opensearch/index/mapper/DerivedField.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.opensearch.script.Script;

import java.io.IOException;
import java.util.Objects;

/**
* DerivedField representation: expects a name, type and script.
Expand Down Expand Up @@ -69,4 +70,23 @@ public Script getScript() {
return script;
}

@Override
public int hashCode() {
return Objects.hash(name, type, script);
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DerivedField other = (DerivedField) obj;
return Objects.equals(name, other.name)
&& Objects.equals(type, other.type)
&& Objects.equals(script, other.script);
}

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

private final Parameter<Script> script = new Parameter<>(
"script",
Expand Down

0 comments on commit d885872

Please sign in to comment.