Package lumis.portal.bigdata.query
Class NestedObjectAggregation
- java.lang.Object
-
- lumis.portal.bigdata.query.AbstractSubAggregationAwareAggregation
-
- lumis.portal.bigdata.query.NestedObjectAggregation
-
- All Implemented Interfaces:
IAggregation
,ISubAggregationAwareAggregation
@StableMinor(version="14.0", sinceVersion="11.2") public class NestedObjectAggregation extends AbstractSubAggregationAwareAggregation
This aggregation should be used mainly when some aggregations must be performed over fields inside anested object field
.
In this case, the aggregations should be added as sub-aggregations of anested object aggregation
.
For example, suppose we have a persondocument type
with the following fields:
- name (text)
- address (nested object)
- street (keyword)
- number (keyword)
And there are 3 documents in this document type:
- {"name": "Nara Jones"}
- {"name": "Albert Russef", "address": [{"street": "Av Rio Branco", "number": "23"}, {"street": "Av Francisco Bicalho"}]}
- {"name": "Josef Camus", "address": [{"street": "Av Presidente Vargas"}]}
If a filter aggregation must be created with a filter to restrict the documents to those with the fieldaddress.number
, and this filter aggregation has a terms aggregation as sub aggregation, the terms aggregation result will have the bucketsAv Rio Branco
andAv Francisco Bicalho
, because, since there's no nested aggregation, both of them will be considered in filter aggregation. This may or may not be desired.
If this is not the expected behavior, the filter aggregation should be wrapped inside a nested object aggregation. When this query is performed, the terms aggregation would result in a single bucket:Av Rio Branco
. This result is because with the nested object aggregation, both filter and terms aggregation will be applied in the same nested objects.
This aggregation produces aINestedObjectAggregationResult
.- Since:
- 11.2.0
- Version:
- $Revision: 24477 $ $Date: 2021-04-28 11:30:36 -0300 (Wed, 28 Apr 2021) $
-
-
Constructor Summary
Constructors Constructor Description NestedObjectAggregation(String id, CompositeDocumentTypeField path)
Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getId()
Returns the aggregation identifier.CompositeDocumentTypeField
getPath()
Returns the path of nested field.-
Methods inherited from class lumis.portal.bigdata.query.AbstractSubAggregationAwareAggregation
addSubAggregation, addSubAggregations, addSubAggregations, getSubAggregations
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface lumis.portal.bigdata.query.IAggregation
getId
-
-
-
-
Field Detail
-
id
protected final String id
-
-
Constructor Detail
-
NestedObjectAggregation
public NestedObjectAggregation(String id, CompositeDocumentTypeField path)
Create a new instance.- Parameters:
id
- the aggregation identifier.path
- the path of nested field.- Since:
- 11.2.0
-
-
Method Detail
-
getPath
public CompositeDocumentTypeField getPath()
Returns the path of nested field.- Returns:
- the path of nested field.
- Since:
- 11.2.0
-
getId
public String getId()
Description copied from interface:IAggregation
Returns the aggregation identifier.- Specified by:
getId
in interfaceIAggregation
- Returns:
- the aggregation identifier.
-
-