public MultiValuesSourceFieldConfig build() { if (Strings.isNullOrEmpty(fieldName) && script == null) { throw new IllegalArgumentException("[" + ParseField.CommonFields.FIELD.getPreferredName() + "] and [" + Script.SCRIPT_PARSE_FIELD.getPreferredName() + "] cannot both be null. " + "Please specify one or the other."); } if (Strings.isNullOrEmpty(fieldName) == false && script != null) { throw new IllegalArgumentException("[" + ParseField.CommonFields.FIELD.getPreferredName() + "] and [" + Script.SCRIPT_PARSE_FIELD.getPreferredName() + "] cannot both be configured. " + "Please specify one or the other."); } return new MultiValuesSourceFieldConfig(fieldName, missing, script, timeZone); } }
@Override protected final MultiValuesSourceAggregatorFactory<VS, ?> doBuild(SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException { ValueType finalValueType = this.valueType != null ? this.valueType : targetValueType; Map<String, ValuesSourceConfig<VS>> configs = new HashMap<>(fields.size()); fields.forEach((key, value) -> { ValuesSourceConfig<VS> config = ValuesSourceConfig.resolve(context.getQueryShardContext(), finalValueType, value.getFieldName(), value.getScript(), value.getMissing(), value.getTimeZone(), format); configs.put(key, config); }); DocValueFormat docValueFormat = resolveFormat(format, finalValueType); return innerBuild(context, configs, docValueFormat, parent, subFactoriesBuilder); }
@Override protected final void doWriteTo(StreamOutput out) throws IOException { if (serializeTargetValueType()) { out.writeOptionalWriteable(targetValueType); } out.writeMap(fields, StreamOutput::writeString, (o, value) -> value.writeTo(o)); out.writeOptionalWriteable(valueType); out.writeOptionalString(format); innerWriteTo(out); }
@Override protected final MultiValuesSourceAggregatorFactory<VS, ?> doBuild(SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException { ValueType finalValueType = this.valueType != null ? this.valueType : targetValueType; Map<String, ValuesSourceConfig<VS>> configs = new HashMap<>(fields.size()); fields.forEach((key, value) -> { ValuesSourceConfig<VS> config = ValuesSourceConfig.resolve(context.getQueryShardContext(), finalValueType, value.getFieldName(), value.getScript(), value.getMissing(), value.getTimeZone(), format); configs.put(key, config); }); DocValueFormat docValueFormat = resolveFormat(format, finalValueType); return innerBuild(context, configs, docValueFormat, parent, subFactoriesBuilder); }
@Override protected final void doWriteTo(StreamOutput out) throws IOException { if (serializeTargetValueType()) { out.writeOptionalWriteable(targetValueType); } out.writeMap(fields, StreamOutput::writeString, (o, value) -> value.writeTo(o)); out.writeOptionalWriteable(valueType); out.writeOptionalString(format); innerWriteTo(out); }
public MultiValuesSourceFieldConfig build() { if (Strings.isNullOrEmpty(fieldName) && script == null) { throw new IllegalArgumentException("[" + ParseField.CommonFields.FIELD.getPreferredName() + "] and [" + Script.SCRIPT_PARSE_FIELD.getPreferredName() + "] cannot both be null. " + "Please specify one or the other."); } if (Strings.isNullOrEmpty(fieldName) == false && script != null) { throw new IllegalArgumentException("[" + ParseField.CommonFields.FIELD.getPreferredName() + "] and [" + Script.SCRIPT_PARSE_FIELD.getPreferredName() + "] cannot both be configured. " + "Please specify one or the other."); } return new MultiValuesSourceFieldConfig(fieldName, missing, script, timeZone); } }
@Override protected final MultiValuesSourceAggregatorFactory<VS, ?> doBuild(SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException { ValueType finalValueType = this.valueType != null ? this.valueType : targetValueType; Map<String, ValuesSourceConfig<VS>> configs = new HashMap<>(fields.size()); fields.forEach((key, value) -> { ValuesSourceConfig<VS> config = ValuesSourceConfig.resolve(context.getQueryShardContext(), finalValueType, value.getFieldName(), value.getScript(), value.getMissing(), value.getTimeZone(), format); configs.put(key, config); }); DocValueFormat docValueFormat = resolveFormat(format, finalValueType); return innerBuild(context, configs, docValueFormat, parent, subFactoriesBuilder); }
@Override protected final void doWriteTo(StreamOutput out) throws IOException { if (serializeTargetValueType()) { out.writeOptionalWriteable(targetValueType); } out.writeMap(fields, StreamOutput::writeString, (o, value) -> value.writeTo(o)); out.writeOptionalWriteable(valueType); out.writeOptionalString(format); innerWriteTo(out); }
public MultiValuesSourceFieldConfig build() { if (Strings.isNullOrEmpty(fieldName) && script == null) { throw new IllegalArgumentException("[" + ParseField.CommonFields.FIELD.getPreferredName() + "] and [" + Script.SCRIPT_PARSE_FIELD.getPreferredName() + "] cannot both be null. " + "Please specify one or the other."); } if (Strings.isNullOrEmpty(fieldName) == false && script != null) { throw new IllegalArgumentException("[" + ParseField.CommonFields.FIELD.getPreferredName() + "] and [" + Script.SCRIPT_PARSE_FIELD.getPreferredName() + "] cannot both be configured. " + "Please specify one or the other."); } return new MultiValuesSourceFieldConfig(fieldName, missing, script, timeZone); } }