|
@@ -25,16 +25,17 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.Writeable;
|
|
import org.elasticsearch.common.io.stream.Writeable;
|
|
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
|
|
-import org.elasticsearch.common.xcontent.ToXContentFragment;
|
|
|
|
|
|
|
+import org.elasticsearch.common.xcontent.ToXContentObject;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.common.xcontent.XContentParser;
|
|
import org.elasticsearch.common.xcontent.XContentParser;
|
|
|
import org.elasticsearch.script.Script;
|
|
import org.elasticsearch.script.Script;
|
|
|
import org.joda.time.DateTimeZone;
|
|
import org.joda.time.DateTimeZone;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
+import java.util.Objects;
|
|
|
import java.util.function.BiFunction;
|
|
import java.util.function.BiFunction;
|
|
|
|
|
|
|
|
-public class MultiValuesSourceFieldConfig implements Writeable, ToXContentFragment {
|
|
|
|
|
|
|
+public class MultiValuesSourceFieldConfig implements Writeable, ToXContentObject {
|
|
|
private String fieldName;
|
|
private String fieldName;
|
|
|
private Object missing;
|
|
private Object missing;
|
|
|
private Script script;
|
|
private Script script;
|
|
@@ -110,6 +111,7 @@ public class MultiValuesSourceFieldConfig implements Writeable, ToXContentFragme
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
|
|
|
+ builder.startObject();
|
|
|
if (missing != null) {
|
|
if (missing != null) {
|
|
|
builder.field(ParseField.CommonFields.MISSING.getPreferredName(), missing);
|
|
builder.field(ParseField.CommonFields.MISSING.getPreferredName(), missing);
|
|
|
}
|
|
}
|
|
@@ -120,11 +122,33 @@ public class MultiValuesSourceFieldConfig implements Writeable, ToXContentFragme
|
|
|
builder.field(ParseField.CommonFields.FIELD.getPreferredName(), fieldName);
|
|
builder.field(ParseField.CommonFields.FIELD.getPreferredName(), fieldName);
|
|
|
}
|
|
}
|
|
|
if (timeZone != null) {
|
|
if (timeZone != null) {
|
|
|
- builder.field(ParseField.CommonFields.TIME_ZONE.getPreferredName(), timeZone);
|
|
|
|
|
|
|
+ builder.field(ParseField.CommonFields.TIME_ZONE.getPreferredName(), timeZone.getID());
|
|
|
}
|
|
}
|
|
|
|
|
+ builder.endObject();
|
|
|
return builder;
|
|
return builder;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean equals(Object o) {
|
|
|
|
|
+ if (this == o) return true;
|
|
|
|
|
+ if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
|
+ MultiValuesSourceFieldConfig that = (MultiValuesSourceFieldConfig) o;
|
|
|
|
|
+ return Objects.equals(fieldName, that.fieldName)
|
|
|
|
|
+ && Objects.equals(missing, that.missing)
|
|
|
|
|
+ && Objects.equals(script, that.script)
|
|
|
|
|
+ && Objects.equals(timeZone, that.timeZone);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int hashCode() {
|
|
|
|
|
+ return Objects.hash(fieldName, missing, script, timeZone);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String toString() {
|
|
|
|
|
+ return Strings.toString(this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static class Builder {
|
|
public static class Builder {
|
|
|
private String fieldName;
|
|
private String fieldName;
|
|
|
private Object missing = null;
|
|
private Object missing = null;
|