Skip to content

Commit bbd083c

Browse files
authored
DEV: add TCEs to query > aggregation page (#689)
1 parent 08c412f commit bbd083c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

content/develop/interact/search-and-query/query/aggregation.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ Here is a more detailed explanation of the query syntax:
4646

4747
The following example shows you how to calculate a discounted price for new bicycles:
4848

49-
```
49+
{{< clients-example query_agg agg1 >}}
5050
FT.AGGREGATE idx:bicycle "@condition:{new}" LOAD 2 "__key" "price" APPLY "@price - (@price * 0.1)" AS "discounted"
51-
```
51+
{{< /clients-example >}}
5252

5353
The field `__key` is a built-in field.
5454

@@ -92,9 +92,9 @@ Here is an explanation of the additional constructs:
9292

9393
The following query shows you how to group by the field `condition` and apply a reduction based on the previously derived `price_category`. The expression `@price<1000` causes a bicycle to have the price category `1` if its price is lower than 1000 USD. Otherwise, it has the price category `0`. The output is the number of affordable bicycles grouped by price category.
9494

95-
```
95+
{{< clients-example query_agg agg2 >}}
9696
FT.AGGREGATE idx:bicycle "*" LOAD 1 price APPLY "@price<1000" AS price_category GROUPBY 1 @condition REDUCE SUM 1 "@price_category" AS "num_affordable"
97-
```
97+
{{< /clients-example >}}
9898

9999
```
100100
1) "3"
@@ -123,9 +123,9 @@ You can't use an aggregation function outside of a `GROUPBY` clause, but you can
123123

124124
Here is an example that adds a type attribute `bicycle` to each document before counting all documents with that type:
125125

126-
```
126+
{{< clients-example query_agg agg3 >}}
127127
FT.AGGREGATE idx:bicycle "*" APPLY "'bicycle'" AS type GROUPBY 1 @type REDUCE COUNT 0 AS num_total
128-
```
128+
{{< /clients-example >}}
129129

130130
The result is:
131131

@@ -143,28 +143,28 @@ It's sometimes necessary to group your data without applying a mathematical aggr
143143

144144
The following example shows how to group all bicycles by `condition`:
145145

146-
```
147-
FT.AGGREGATE idx:bicycle "*" LOAD 1 "__key" GROUPBY 1 "@condition" REDUCE TOLIST 1 "__key" AS bicylces
148-
```
146+
{{< clients-example query_agg agg4 >}}
147+
FT.AGGREGATE idx:bicycle "*" LOAD 1 "__key" GROUPBY 1 "@condition" REDUCE TOLIST 1 "__key" AS bicycles
148+
{{< /clients-example >}}
149149

150150
The output of this query is:
151151

152152
```
153153
1) "3"
154154
2) 1) "condition"
155155
1) "refurbished"
156-
2) "bicylces"
156+
2) "bicycles"
157157
3) 1) "bicycle:9"
158158
3) 1) "condition"
159159
1) "used"
160-
2) "bicylces"
160+
2) "bicycles"
161161
3) 1) "bicycle:1"
162162
1) "bicycle:2"
163163
2) "bicycle:3"
164164
3) "bicycle:4"
165165
4) 1) "condition"
166166
1) "new"
167-
2) "bicylces"
167+
2) "bicycles"
168168
3) 1) "bicycle:0"
169169
1) "bicycle:5"
170170
2) "bicycle:6"

0 commit comments

Comments
 (0)