Adding null check for ParentJoinFieldMapper in ChildrenAggregationBuilder.joinFieldResolveConfig Closes #42997 Co-authored-by: ParthPunkster <parthjain.pj1994@gmail.com>
This commit is contained in:
parent
2a1635ad69
commit
2965c7fe12
|
@ -112,17 +112,25 @@ public class ChildrenAggregationBuilder extends ValuesSourceAggregationBuilder<C
|
|||
@Override
|
||||
protected ValuesSourceConfig resolveConfig(QueryShardContext queryShardContext) {
|
||||
ValuesSourceConfig config;
|
||||
|
||||
ParentJoinFieldMapper parentJoinFieldMapper = ParentJoinFieldMapper.getMapper(queryShardContext.getMapperService());
|
||||
if (parentJoinFieldMapper == null) {
|
||||
// Unmapped field case
|
||||
config = ValuesSourceConfig.resolveUnmapped(defaultValueSourceType(), queryShardContext);
|
||||
return config;
|
||||
}
|
||||
|
||||
ParentIdFieldMapper parentIdFieldMapper = parentJoinFieldMapper.getParentIdFieldMapper(childType, false);
|
||||
if (parentIdFieldMapper != null) {
|
||||
if (parentIdFieldMapper == null) {
|
||||
// Unmapped field case
|
||||
config = ValuesSourceConfig.resolveUnmapped(defaultValueSourceType(), queryShardContext);
|
||||
return config;
|
||||
}
|
||||
|
||||
parentFilter = parentIdFieldMapper.getParentFilter();
|
||||
childFilter = parentIdFieldMapper.getChildFilter(childType);
|
||||
MappedFieldType fieldType = parentIdFieldMapper.fieldType();
|
||||
config = ValuesSourceConfig.resolveFieldOnly(fieldType, queryShardContext);
|
||||
} else {
|
||||
// Unmapped field case
|
||||
config = ValuesSourceConfig.resolveUnmapped(defaultValueSourceType(), queryShardContext);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
"unconfigured":
|
||||
- do:
|
||||
index:
|
||||
index: test
|
||||
refresh: true
|
||||
body:
|
||||
join:
|
||||
name: question
|
||||
body: <p>I have Windows 2003 server and i bought a new Windows 2008 server...,
|
||||
title: Whats the best way to file transfer my site from server to a newer one?,
|
||||
tags: [windows-server-2003, windows-server-2008, file-transfer]
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: test
|
||||
body:
|
||||
size: 0
|
||||
aggs:
|
||||
to-answers:
|
||||
children:
|
||||
type: answer
|
||||
- match: { hits.total.value: 1 }
|
||||
- match: { aggregations.to-answers.doc_count: 0 }
|
Loading…
Reference in New Issue