The same way as the Filters section, the Aggregations section as DynamicAggregationType to hold all types of Aggregations.

It has an abstract class DynamicAgg which is being used as the base of every specific aggregation. It has an output to the UI, that's why it has a DynamicAggUI class with exclusive options regarding UI.

DynamicAgg

PropertyDescriptionDefaultTypeRequired
typeAggregation type
stringYes
fieldName of the field from which the values will be aggregated
stringYes
negatedNegates the filterfalsebooleanNo
mustIndicates if the filter must be enforced alongside other filters, or if it can be omitted if it doesn't match (acts as a should)truebooleanNo
post_searchIs filter multiselect? Warning: for multiselect filter, the process is done post searchfalsebooleanNo
idName for which to identify the aggregation done
string (pattern: \w)Yes
or_selectionIndicates the behavior between 2 selections of the same aggregation. If true, selections will be treated as "or" (e.g., A or B). If false, they will be treated as "and" (e.g., A and B)truebooleanNo
ui_onlySection dedicated for UI transformation options only. Not required for regular aggregation process
objectNo
aggsNested Aggregations. Define a list of nested aggregations
arrayNo

The type property should be one of the following values: "term", "bool", "date_histogram", "histogram", "browse", "date_range", "range", "slider", "top_hits", or "filter".

DynamicAggUI

PropertyDescriptionDefaultTypeRequired
display_namePlease use for UI display'Display Name'strYes
hide_countHides the count of the aggregation. Useful for multi-select aggregations.FalseboolYes
translateSet the description prefix for its values. (e.g main.agg.types.<value_of_agg>)NoneOptional[str]No
expandedIf the UI component is collapsible, indicates if it is expanded or notTrueboolYes



Generate Aggregations Workflow

From the connection with the search engine, the generate_aggregations method is executed. This method originates from the Aggregation Factory class, which serves as the base for the specific Factory classes for each search engine. The generate_aggregations method receives a list of DynamicAgg objects provided by the user. This method is responsible for taking each element from that list and transforming it into the corresponding specific aggregation type. At the end of the cycle, it returns a dictionary containing all the aggregations in their specific formats.



In a similar way, the generate_aggregation_filters method inside the base_engine file, will translate the DynamicAgg objects into DynamicFilters, and finally into Engine Specific Filters. 

SelectionAgg

PropertyDescriptionDefaultTypeRequired
idName for which to identify the aggregation done'Aggregation Id'str (regex: '\w')Yes
negatedList of values or ranges for exclusion filteringNoneList[Any]No
valuesList of values or ranges for inclusion filteringNoneList[Any]No
levelLevel of Deepness for histograms configuration0intNo


SearchFilters

PropertyDescriptionDefaultTypeRequired
should_notFilter acting as a boolean operator NOR for optional exclusion.Nonelist[dict]No
shouldFilter acting as a boolean operator OR for optional inclusion.Nonelist[dict]No
must_notFilter acting as a boolean operator NAND for exclusion.Nonelist[dict]No
mustFilter acting as a boolean operator AND for inclusion.Nonelist[dict]No
post_should_notFilter acting as a boolean operator NOR for optional exclusion after the main query.Nonelist[dict]No
post_shouldFilter acting as a boolean operator OR for optional inclusion after the main query.Nonelist[dict]No
post_must_notFilter acting as a boolean operator NAND for exclusion after the main query.Nonelist[dict]No
post_mustFilter acting as a boolean operator AND for inclusion after the main query.Nonelist[dict]No




ResponseAgg

PropertyDescriptionDefaultTypeRequired
idUnique identifier for the returned aggregation
str (alias: '_id')    Yes
entriesEach individual value for an aggregationNonelist[AggEntry, Any]No


AggEntry

PropertyDescriptionDefaultTypeRequired
countThe count of the aggregation entry0intNo
aggsA list of nested ResponseAgg objects, or NoneNoneUnion[List[ResponseAgg], None]No
  • No labels