if (unmapped()) { if (missing() == null) {
public SignificantTermsAggregatorFactory(String name, ValuesSourceConfig<ValuesSource> config, IncludeExclude includeExclude, String executionHint, QueryBuilder filterBuilder, TermsAggregator.BucketCountThresholds bucketCountThresholds, SignificanceHeuristic significanceHeuristic, SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException { super(name, config, context, parent, subFactoriesBuilder, metaData); if (!config.unmapped()) { this.fieldType = config.fieldContext().fieldType(); this.indexedFieldName = fieldType.name(); } this.includeExclude = includeExclude; this.executionHint = executionHint; this.filter = filterBuilder == null ? null : filterBuilder.toFilter(context.getQueryShardContext()); IndexSearcher searcher = context.searcher(); this.supersetNumDocs = filter == null // Important - need to use the doc count that includes deleted docs // or we have this issue: https://github.com/elastic/elasticsearch/issues/7951 ? searcher.getIndexReader().maxDoc() : searcher.count(filter); this.bucketCountThresholds = bucketCountThresholds; this.significanceHeuristic = significanceHeuristic; }
private void setFieldInfo(SearchContext context) { if (!config.unmapped()) { this.indexedFieldName = config.fieldContext().field(); fieldType = context.smartNameFieldType(indexedFieldName); } }
config.timezone(timeZone); config.format(resolveFormat(format, valueType, timeZone)); config.unmapped(true); if (valueType != null) {
public SignificantTermsAggregatorFactory(String name, ValuesSourceConfig valueSourceConfig, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, String executionHint, Query filter, SignificanceHeuristic significanceHeuristic) { super(name, SignificantStringTerms.TYPE.name(), valueSourceConfig); this.bucketCountThresholds = bucketCountThresholds; this.includeExclude = includeExclude; this.executionHint = executionHint; this.significanceHeuristic = significanceHeuristic; if (!valueSourceConfig.unmapped()) { this.indexedFieldName = config.fieldContext().field(); fieldType = SearchContext.current().smartNameFieldType(indexedFieldName); } this.filter = filter; }
public final CompositeValuesSourceConfig build(SearchContext context) throws IOException { ValuesSourceConfig<?> config = ValuesSourceConfig.resolve(context.getQueryShardContext(), valueType, field, script, missing, null, format); if (config.unmapped() && field != null && missing == null && missingBucket == false) { // this source cannot produce any values so we refuse to build // since composite buckets are not created on null values by default. throw new QueryShardException(context.getQueryShardContext(), "failed to find field [" + field + "] and [missing_bucket] is not set"); } if (missingBucket && missing != null) { throw new QueryShardException(context.getQueryShardContext(), "cannot use [missing] option in conjunction with [missing_bucket]"); } return innerBuild(context, config); } }
public final CompositeValuesSourceConfig build(SearchContext context) throws IOException { ValuesSourceConfig<?> config = ValuesSourceConfig.resolve(context.getQueryShardContext(), valueType, field, script, missing, null, format); if (config.unmapped() && field != null && missing == null && missingBucket == false) { // this source cannot produce any values so we refuse to build // since composite buckets are not created on null values by default. throw new QueryShardException(context.getQueryShardContext(), "failed to find field [" + field + "] and [missing_bucket] is not set"); } if (missingBucket && missing != null) { throw new QueryShardException(context.getQueryShardContext(), "cannot use [missing] option in conjunction with [missing_bucket]"); } return innerBuild(context, config); } }
private void parentFieldResolveConfig(SearchContext context, ValuesSourceConfig<WithOrdinals> config) { DocumentMapper childDocMapper = context.mapperService().documentMapper(childType); if (childDocMapper != null) { ParentFieldMapper parentFieldMapper = childDocMapper.parentFieldMapper(); if (!parentFieldMapper.active()) { throw new IllegalArgumentException("[children] no [_parent] field not configured that points to a parent type"); } String parentType = parentFieldMapper.type(); DocumentMapper parentDocMapper = context.mapperService().documentMapper(parentType); if (parentDocMapper != null) { parentFilter = parentDocMapper.typeFilter(context.getQueryShardContext()); childFilter = childDocMapper.typeFilter(context.getQueryShardContext()); MappedFieldType parentFieldType = parentDocMapper.parentFieldMapper().getParentJoinFieldType(); final SortedSetDVOrdinalsIndexFieldData fieldData = context.getForField(parentFieldType); config.fieldContext(new FieldContext(parentFieldType.name(), fieldData, parentFieldType)); } else { config.unmapped(true); } } else { config.unmapped(true); } }
if (unmapped()) { if (missing() == null) {
private void parentFieldResolveConfig(SearchContext context, ValuesSourceConfig<WithOrdinals> config) { DocumentMapper childDocMapper = context.mapperService().documentMapper(childType); if (childDocMapper != null) { ParentFieldMapper parentFieldMapper = childDocMapper.parentFieldMapper(); if (!parentFieldMapper.active()) { throw new IllegalArgumentException("[children] no [_parent] field not configured that points to a parent type"); } String parentType = parentFieldMapper.type(); DocumentMapper parentDocMapper = context.mapperService().documentMapper(parentType); if (parentDocMapper != null) { parentFilter = parentDocMapper.typeFilter(context.getQueryShardContext()); childFilter = childDocMapper.typeFilter(context.getQueryShardContext()); MappedFieldType parentFieldType = parentDocMapper.parentFieldMapper().getParentJoinFieldType(); final SortedSetDVOrdinalsIndexFieldData fieldData = context.getForField(parentFieldType); config.fieldContext(new FieldContext(parentFieldType.name(), fieldData, parentFieldType)); } else { config.unmapped(true); } } else { config.unmapped(true); } }
private void parentFieldResolveConfig(SearchContext context, ValuesSourceConfig<WithOrdinals> config) { DocumentMapper childDocMapper = context.mapperService().documentMapper(childType); if (childDocMapper != null) { ParentFieldMapper parentFieldMapper = childDocMapper.parentFieldMapper(); if (!parentFieldMapper.active()) { throw new IllegalArgumentException("[children] no [_parent] field not configured that points to a parent type"); } String parentType = parentFieldMapper.type(); DocumentMapper parentDocMapper = context.mapperService().documentMapper(parentType); if (parentDocMapper != null) { parentFilter = parentDocMapper.typeFilter(context.getQueryShardContext()); childFilter = childDocMapper.typeFilter(context.getQueryShardContext()); MappedFieldType parentFieldType = parentDocMapper.parentFieldMapper().getParentJoinFieldType(); final SortedSetDVOrdinalsIndexFieldData fieldData = context.getForField(parentFieldType); config.fieldContext(new FieldContext(parentFieldType.name(), fieldData, parentFieldType)); } else { config.unmapped(true); } } else { config.unmapped(true); } }
private void joinFieldResolveConfig(SearchContext context, ValuesSourceConfig<WithOrdinals> config) { ParentJoinFieldMapper parentJoinFieldMapper = ParentJoinFieldMapper.getMapper(context.mapperService()); ParentIdFieldMapper parentIdFieldMapper = parentJoinFieldMapper.getParentIdFieldMapper(childType, false); if (parentIdFieldMapper != null) { parentFilter = parentIdFieldMapper.getParentFilter(); childFilter = parentIdFieldMapper.getChildFilter(childType); MappedFieldType fieldType = parentIdFieldMapper.fieldType(); final SortedSetDVOrdinalsIndexFieldData fieldData = context.getForField(fieldType); config.fieldContext(new FieldContext(fieldType.name(), fieldData, fieldType)); } else { config.unmapped(true); } }
private void joinFieldResolveConfig(SearchContext context, ValuesSourceConfig<WithOrdinals> config) { ParentJoinFieldMapper parentJoinFieldMapper = ParentJoinFieldMapper.getMapper(context.mapperService()); ParentIdFieldMapper parentIdFieldMapper = parentJoinFieldMapper.getParentIdFieldMapper(childType, false); if (parentIdFieldMapper != null) { parentFilter = parentIdFieldMapper.getParentFilter(); childFilter = parentIdFieldMapper.getChildFilter(childType); MappedFieldType fieldType = parentIdFieldMapper.fieldType(); final SortedSetDVOrdinalsIndexFieldData fieldData = context.getForField(fieldType); config.fieldContext(new FieldContext(fieldType.name(), fieldData, fieldType)); } else { config.unmapped(true); } }
private void joinFieldResolveConfig(SearchContext context, ValuesSourceConfig<WithOrdinals> config) { ParentJoinFieldMapper parentJoinFieldMapper = ParentJoinFieldMapper.getMapper(context.mapperService()); ParentIdFieldMapper parentIdFieldMapper = parentJoinFieldMapper.getParentIdFieldMapper(childType, false); if (parentIdFieldMapper != null) { parentFilter = parentIdFieldMapper.getParentFilter(); childFilter = parentIdFieldMapper.getChildFilter(childType); MappedFieldType fieldType = parentIdFieldMapper.fieldType(); final SortedSetDVOrdinalsIndexFieldData fieldData = context.getForField(fieldType); config.fieldContext(new FieldContext(fieldType.name(), fieldData, fieldType)); } else { config.unmapped(true); } }
private void joinFieldResolveConfig(SearchContext context, ValuesSourceConfig<WithOrdinals> config) { ParentJoinFieldMapper parentJoinFieldMapper = ParentJoinFieldMapper.getMapper(context.mapperService()); ParentIdFieldMapper parentIdFieldMapper = parentJoinFieldMapper.getParentIdFieldMapper(childType, false); if (parentIdFieldMapper != null) { parentFilter = parentIdFieldMapper.getParentFilter(); childFilter = parentIdFieldMapper.getChildFilter(childType); MappedFieldType fieldType = parentIdFieldMapper.fieldType(); final SortedSetDVOrdinalsIndexFieldData fieldData = context.getForField(fieldType); config.fieldContext(new FieldContext(fieldType.name(), fieldData, fieldType)); } else { config.unmapped(true); } }
private void joinFieldResolveConfig(SearchContext context, ValuesSourceConfig<WithOrdinals> config) { ParentJoinFieldMapper parentJoinFieldMapper = ParentJoinFieldMapper.getMapper(context.mapperService()); ParentIdFieldMapper parentIdFieldMapper = parentJoinFieldMapper.getParentIdFieldMapper(childType, false); if (parentIdFieldMapper != null) { parentFilter = parentIdFieldMapper.getParentFilter(); childFilter = parentIdFieldMapper.getChildFilter(childType); MappedFieldType fieldType = parentIdFieldMapper.fieldType(); final SortedSetDVOrdinalsIndexFieldData fieldData = context.getForField(fieldType); config.fieldContext(new FieldContext(fieldType.name(), fieldData, fieldType)); } else { config.unmapped(true); } }
public SignificantTermsAggregatorFactory(String name, ValuesSourceConfig<ValuesSource> config, IncludeExclude includeExclude, String executionHint, QueryBuilder filterBuilder, TermsAggregator.BucketCountThresholds bucketCountThresholds, SignificanceHeuristic significanceHeuristic, SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException { super(name, config, context, parent, subFactoriesBuilder, metaData); if (!config.unmapped()) { this.fieldType = config.fieldContext().fieldType(); this.indexedFieldName = fieldType.name(); } this.includeExclude = includeExclude; this.executionHint = executionHint; this.filter = filterBuilder == null ? null : filterBuilder.toFilter(context.getQueryShardContext()); IndexSearcher searcher = context.searcher(); this.supersetNumDocs = filter == null // Important - need to use the doc count that includes deleted docs // or we have this issue: https://github.com/elastic/elasticsearch/issues/7951 ? searcher.getIndexReader().maxDoc() : searcher.count(filter); this.bucketCountThresholds = bucketCountThresholds; this.significanceHeuristic = significanceHeuristic; }
public SignificantTermsAggregatorFactory(String name, ValuesSourceConfig<ValuesSource> config, IncludeExclude includeExclude, String executionHint, QueryBuilder filterBuilder, TermsAggregator.BucketCountThresholds bucketCountThresholds, SignificanceHeuristic significanceHeuristic, SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException { super(name, config, context, parent, subFactoriesBuilder, metaData); if (!config.unmapped()) { this.fieldType = config.fieldContext().fieldType(); this.indexedFieldName = fieldType.name(); } this.includeExclude = includeExclude; this.executionHint = executionHint; this.filter = filterBuilder == null ? null : filterBuilder.toFilter(context.getQueryShardContext()); IndexSearcher searcher = context.searcher(); this.supersetNumDocs = filter == null // Important - need to use the doc count that includes deleted docs // or we have this issue: https://github.com/elastic/elasticsearch/issues/7951 ? searcher.getIndexReader().maxDoc() : searcher.count(filter); this.bucketCountThresholds = bucketCountThresholds; this.significanceHeuristic = significanceHeuristic; }
config.missing(missingMap.get(field)); config.format(resolveFormat(format, valueType)); return config.unmapped(true);
config.missing(missingMap.get(field)); config.format(resolveFormat(format, valueType)); return config.unmapped(true);