UpStart Commerce Search
Aggregations
9min
aggregations represent similar fields in multiple documents allowing you to filter results accordingly they allow users to analyze already searched and returned data and extract statistics from the aggregated data for facilitation purposes, there are multiple apis present that can be called to create, update, or manage aggregations the purpose of this document is to understand the functionality behind them default aggregations if there are no specified aggregations at the time of query, default aggregations are triggered the user doesn't need to define their priority users can always set a basic default aggregation with the highest priority and no condition later, other default aggregations with lower priority can be defined but with a condition that overrules the basic one this is because a single default aggregation can be applied on the query and only on the condition that no aggregation was applied before note the difference between aggregation appenders and default aggregations is that only 1 default aggregation can be applied at a time on the other hand, multiple aggregation appenders can be applied simultaneously it is also important to remember that default aggregations require no nochannel search aggregation to be applied before attach this endpoint allows users to attach default aggregations with a query pipeline users can attach one default aggregation with multiple query pipelines the api call to attach the default aggregation is post https //api upstartcommerce com/v1/search/default aggregation/attach/resource id/to/querypipeline notice that the default aggregations' id is added before 'to' and after it, the query pipeline id is defined detach the detach function allows users to remove a particular default aggregation from the query pipeline the api call to detach the default aggregation is post https //api upstartcommerce com/v1/search/default aggregation/detach/resource id/from/querypipeline notice that the id of the default aggregation is added before 'from' and after it, the query pipeline id is defined types of aggregations there are multiple types of aggregations apart from the aggregations offered by opensearch, nochannel search provides its users with different aggregations to facilitate the searching process managed aggregations managed aggregations are aggregations that are given some properties such as a name through which they can be referred this facilitates the client at the time of performing queries because of the stable identifiers that are associated with them all the aggregations are present in the same place making it easier to manage them all from a single place managed aggregations are categorized based on terms or ranges to understand their functionality better refer to the opensearch documentation aggregationref aggregationref are the aggregations that are used to point or refer towards an existing managed or aggregation set this is a nochannel search specific aggregation to understand them better, consider the following code block "id" "my default aggregation", "priority" 1, "condition" { "type" "queryhasfield", "field" "gender", "value" "m" }, "aggregations" \[ { "type" "aggregationref", "ref" "some managed agg" } ] in the example above, in the aggregations block, once the type is defined, a reference "ref" pointer is specified to a pre existing managed aggregation aggregationsets multiple aggregations grouped by a set of properties such as brand names, sizes, and other similar fields are called aggregation sets it is important to remember that the resulting sets are also aggregations this is another nochannel search specific aggregation for example, a user can create an aggregation set for "fruits" with individual aggregations such as "season summer, winter", "price range $1, $100", and so on any time a query is made regarding fruits, the generated result will be retrieved from the aggregation set continuing the example used in managed aggregation consider the following code block for the creation of an aggregation set the api call to create an aggregation set is post https //api upstartcommerce com/v1/search/aggregation { "id" "agg set", "displayname" "my agg set", "aggregation" { "name" "agg set", "priority" 10, "type" "aggregationset", "refs" \[ "brandname term", "price facet" ] }, "status" "active" } the unique field is refs this is an array that includes multiple managed aggregations that are to become a part of the aggregation set in the example above, those are brandname term and price facet aggregation appender through this type of aggregation, aggregations are appended if a certain condition is satisfied this means that if a particular term is searched in the query, a specific aggregation will be appended to the search results to understand the functionality better, go through the documentation of query & query rules docid\ i 7sfhn asmzlgqenvl2y