if (!valid()) { throw new IllegalStateException( "value source config is invalid; must have either a field context or a script or marked as unwrapped");
@Override public void doValidate() { if (config == null || !config.valid()) { resolveValuesSourceConfigFromAncestors(name, parent, config.valueSourceType()); } }
private void resolveValuesSourceConfigFromAncestors(String aggName, AggregatorFactory parent, Class<VS> requiredValuesSourceType) { ValuesSourceConfig config; while (parent != null) { if (parent instanceof ValuesSourceAggregatorFactory) { config = ((ValuesSourceAggregatorFactory) parent).config; if (config != null && config.valid()) { if (requiredValuesSourceType == null || requiredValuesSourceType.isAssignableFrom(config.valueSourceType)) { ValueFormat format = config.format; this.config = config; // if the user explicitly defined a format pattern, we'll do our best to keep it even when we inherit the // value source form one of the ancestor aggregations if (this.config.formatPattern != null && format != null && format instanceof ValueFormat.Patternable) { this.config.format = ((ValueFormat.Patternable) format).create(this.config.formatPattern); } return; } } } parent = parent.parent(); } throw new AggregationExecutionException("could not find the appropriate value context to perform aggregation [" + aggName + "]"); } }
assert config.valid() : "value source config is invalid - must have either a field context or a script or marked as unmapped";
if (!valid()) { throw new IllegalStateException( "value source config is invalid; must have either a field context or a script or marked as unwrapped");
if (!valid()) { throw new IllegalStateException( "value source config is invalid; must have either a field context or a script or marked as unwrapped");
if (!valid()) { throw new IllegalStateException( "value source config is invalid; must have either a field context or a script or marked as unwrapped");
if (vsConfig.valid()) { return new SamplerAggregator.DiversifiedFactory(aggregationName, shardSize, executionHint, vsConfig, maxDocsPerValue); } else {