Skip to content

Commit 9b506cb

Browse files
author
Rachel Artiss
committed
Updating demo, readme, bower, using Polymer style conventions for observers, and adding nestedAggregations to update function.
1 parent 029b186 commit 9b506cb

File tree

6 files changed

+112
-49
lines changed

6 files changed

+112
-49
lines changed

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.yo-rc.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
11
# elastic-client-aggregation-builder
2+
3+
An element which builds an elasticjs aggregation based on the set attributes.
4+
5+
Example:
6+
```html
7+
<elastic-client-aggregation-builder
8+
field="fieldName"
9+
name="aggName"
10+
type="terms"
11+
count="15"
12+
ejs-aggregation="{{ejsAgg}}">
13+
</elastic-client-aggregation>
14+
```
15+
16+
## Dependencies
17+
18+
Element dependencies are managed via [Bower](http://bower.io/). You can
19+
install that via:
20+
21+
npm install -g bower
22+
23+
Then, go ahead and download the element's dependencies:
24+
25+
bower install

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "elastic-client-aggregation-builder",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"authors": [
55
"Next Century Corporation"
66
],
7-
"description": "",
7+
"description": "An element which builds an elasticjs aggregation based on the set attributes",
88
"keywords": [
99
"web-component",
1010
"polymer",

demo/index.html

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,99 @@
1818
</head>
1919
<body unresolved>
2020
<template is="dom-bind" id="demo">
21+
<p>===== DEMO 1 =====</p>
2122
<p>Field: 'myfield'</p>
22-
<p>Name: 'myAgg'</p>
23+
<p>Name: 'myAgg1'</p>
2324
<p>type: 'terms'</p>
2425
<p>count: 15</p>
2526

2627
<elastic-client-aggregation-builder
2728
field="myfield"
28-
name="myAgg"
29+
name="myAgg1"
2930
type="terms"
3031
count="15"
31-
ejs-aggregation="{{agg}}">
32+
ejs-aggregation="{{agg1}}">
3233
</elastic-client-aggregation-builder>
3334

34-
<p><span>ElasticJS aggregation: </span>{{toJSON(agg)}}</p>
35+
<p><span>ElasticJS aggregation: </span>{{stringify(agg1)}}</p>
36+
37+
<p>===== DEMO 2 =====</p>
38+
<p>Field: 'myfield'</p>
39+
<p>Name: 'myAgg2'</p>
40+
<p>type: 'min'</p>
41+
42+
<elastic-client-aggregation-builder
43+
field="myfield"
44+
name="myAgg2"
45+
type="min"
46+
ejs-aggregation="{{agg2}}">
47+
</elastic-client-aggregation-builder>
48+
49+
<p><span>ElasticJS aggregation: </span>{{stringify(agg2)}}</p>
50+
51+
<p>===== DEMO 3 =====</p>
52+
<p>Field: 'myfield'</p>
53+
<p>Name: 'myAgg3'</p>
54+
<p>type: 'date_histogram'</p>
55+
56+
<elastic-client-aggregation-builder
57+
field="myfield"
58+
name="myAgg3"
59+
type="date_histogram"
60+
ejs-aggregation="{{agg3}}">
61+
</elastic-client-aggregation-builder>
62+
63+
<p><span>ElasticJS aggregation: </span>{{stringify(agg3)}}</p>
64+
65+
<p>===== DEMO 4 =====</p>
66+
<p>Field: 'myfield'</p>
67+
<p>Name: 'myAgg4'</p>
68+
<p>type: 'terms'</p>
69+
<p>count: 5</p>
70+
<p>order: 'otherField'</p>
71+
<p>direction: 'desc'</p>
72+
<p>Nested aggregations: [{{stringify(agg3)}}]</p>
73+
74+
<elastic-client-aggregation-builder
75+
field="myfield"
76+
name="myAgg4"
77+
type="terms"
78+
count="5"
79+
ejs-aggregation="{{agg4}}"
80+
nested-aggregations="{{objectToArray(agg3)}}"
81+
order="otherField"
82+
direction="desc">
83+
</elastic-client-aggregation-builder>
84+
85+
<p><span>ElasticJS aggregation: </span>{{stringify(agg4)}}</p>
86+
87+
<p>===== DEMO 5 =====</p>
88+
<p>Field: 'myfield'</p>
89+
<p>Name: 'myAgg5'</p>
90+
<p>type: 'max'</p>
91+
92+
<elastic-client-aggregation-builder
93+
field="myfield"
94+
name="myAgg5"
95+
type="max"
96+
ejs-aggregation="{{agg5}}">
97+
</elastic-client-aggregation-builder>
98+
99+
<p><span>ElasticJS aggregation: </span>{{stringify(agg5)}}</p>
100+
35101
</template>
36102

37103
<script>
38104
(function(document) {
39105
var demo = document.querySelector('#demo');
40106

41-
demo.toJSON = function(ejs) {
107+
demo.stringify = function(ejs) {
42108
return JSON.stringify(ejs);
43-
}
109+
};
110+
111+
demo.objectToArray = function(json) {
112+
return [json];
113+
};
44114
})(document);
45115
</script>
46116
</body>

elastic-client-aggregation-builder.html

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
Example:
88
99
<elastic-client-aggregation-builder
10-
field: "fieldName"
11-
name: "aggName"
12-
type: "terms"
13-
count: "15"
14-
ejs-aggregation: "{{ejsAgg}}"
15-
>
10+
field="fieldName"
11+
name="aggName"
12+
type="terms"
13+
count="15"
14+
ejs-aggregation="{{ejsAgg}}">
1615
</elastic-client-aggregation>
1716
1817
@demo demo/index.html
@@ -105,15 +104,15 @@
105104
},
106105

107106
observers : [
108-
'buildAggregation(field, name, type, nestedAggregations)',
109-
'updateAggregation(count, order, direction)'
107+
'_buildAggregation(field, name, type, nestedAggregations)',
108+
'_updateAggregation(count, order, direction)'
110109
],
111-
updateAggregation: function() {
110+
_updateAggregation: function() {
112111
if(this.ejsAggregation) {
113-
this.buildAggregation(this.field, this.name, this.type);
112+
this._buildAggregation(this.field, this.name, this.type, this.nestedAggregations);
114113
}
115114
},
116-
buildAggregation: function(field, name, type, nestedAggregations) {
115+
_buildAggregation: function(field, name, type, nestedAggregations) {
117116
var ejsAggregation;
118117
if(type === 'terms') {
119118
ejsAggregation = ejs.TermsAggregation(name).field(field).size(this.count);

0 commit comments

Comments
 (0)