0.0.6 | Built motion from commit ffa9431.
[motion.git] / public / assets / plugins / angular-elastic-builder / examples / js / exampleApp.js
1 (function(angular) {
2
3   var app = angular.module('exampleApp', [
4     'angular-elastic-builder',
5   ]);
6
7   app.controller('BasicController', function() {
8
9     var data = this.data = {};
10
11     data.query = [
12       {
13         'and': [
14           {
15             'range': {
16               'test.number': {
17                 'gte': 650
18               }
19             }
20           },
21           {
22             'range': {
23               'test.number': {
24                 'lt': 850
25               }
26             }
27           }
28         ]
29       },
30       {
31         'term': {
32           'test.boolean': 0
33         }
34       },
35       {
36         'terms': {
37           'test.state.multi': [ 'AZ', 'CT' ]
38         }
39       },
40       {
41         'not': {
42           'filter': {
43             'term': {
44               'test.term': 'asdfasdf'
45             }
46           }
47         }
48       },
49       {
50         'exists': {
51           'field': 'test.term'
52         }
53       }
54     ];
55
56     data.fields = {
57       'test.number': { type: 'number', minimum: 650 },
58       'test.term': { type: 'term' },
59       'test.boolean': { type: 'term', subType: 'boolean' },
60       'test.state.multi': { type: 'multi', choices: [ 'AZ', 'CA', 'CT' ]}
61     };
62
63     data.needsUpdate = true;
64
65     this.showQuery = function() {
66       var queryToShow = {
67         size: 0,
68         filter: { and : data.query }
69       };
70
71       return JSON.stringify(queryToShow, null, 2);
72     };
73
74   });
75
76 })(window.angular);