Skip to content

Commit f8eb790

Browse files
committed
write out the example json for wirting aggregations documentation
1 parent 1d6c173 commit f8eb790

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

docs/asciidoc/aggregations/bucket/children/children-aggregation-mapping.asciidoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
[[child-aggregation-mapping]]
88
== Child Aggregation Mapping
99

10-
To use the child aggregation you have to make sure
11-
a `_parent` mapping is in place, here we create the project
12-
index with two mapped types, `project` and `commitactivity` and
13-
we add a `_parent` mapping from `commitactivity` to `parent`
10+
To use the {ref_current}/search-aggregations-bucket-children-aggregation.html[Children Aggregation],
11+
you have to make sure a `_parent` mapping is in place.
12+
13+
Here we create the project index with two mapped types, `Project` and `CommitActivity` and
14+
add a `_parent` mapping to `CommitActivity`, specifying the `Project` type as the parent
1415

1516
[source,csharp]
1617
----

docs/asciidoc/aggregations/writing-aggregations.asciidoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,32 @@ want to use each.
2020

2121
This is the json output for each example
2222

23+
[source,javascript]
24+
.Example json output
25+
----
26+
{
27+
"aggs": {
28+
"name_of_child_agg": {
29+
"children": {
30+
"type": "commits"
31+
},
32+
"aggs": {
33+
"average_per_child": {
34+
"avg": {
35+
"field": "confidenceFactor"
36+
}
37+
},
38+
"max_per_child": {
39+
"max": {
40+
"field": "confidenceFactor"
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
----
48+
2349
=== Fluent DSL
2450

2551
The fluent lambda syntax is the most terse way to write aggregations.

src/CodeGeneration/Nest.Litterateur/AsciiDoc/GeneratedAsciidocVisitor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public override void Visit(Container elements)
118118

119119
if ((method.Value == "expectjson" || method.Value == "queryjson") &&
120120
source.Attributes.Count > 1 &&
121-
source.Attributes[1].Name == "javascript")
121+
source.Attributes[1].Name == "javascript" &&
122+
_destination.Name != "writing-aggregations.asciidoc")
122123
{
123124
exampleJson = source;
124125
continue;

src/Tests/Aggregations/Bucket/Children/ChildrenAggregationMapping.doc.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ public class ChildrenAggregationMapping
88
{
99
private void MappingExample()
1010
{
11-
/** To use the child aggregation you have to make sure
12-
* a `_parent` mapping is in place, here we create the project
13-
* index with two mapped types, `project` and `commitactivity` and
14-
* we add a `_parent` mapping from `commitactivity` to `parent` */
11+
/** To use the {ref_current}/search-aggregations-bucket-children-aggregation.html[Children Aggregation],
12+
* you have to make sure a `_parent` mapping is in place.
13+
*
14+
* Here we create the project index with two mapped types, `Project` and `CommitActivity` and
15+
* add a `_parent` mapping to `CommitActivity`, specifying the `Project` type as the parent */
1516
var createProjectIndex = TestClient.GetClient().CreateIndex(typeof(Project), c => c
1617
.Mappings(map => map
1718
.Map<Project>(tm => tm.AutoMap())

0 commit comments

Comments
 (0)