Skip to content

Commit fdfc04d

Browse files
oguennecdncrews
authored andcommitted
1.5.0 - enhancement dncrews#2 : add term and range searches on date with ui.bootstrap.datepicker
1 parent f494f5d commit fdfc04d

15 files changed

+447
-85
lines changed

README.md

+54-32
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ It's still pretty early on, as it doesn't support a whole lot of use-cases, but
1616
## Usage
1717

1818
### Dependency
19-
Notice: this plugin requires the [Angular Recursion](https://github.com/marklagendijk/angular-recursion) module.
19+
Notice: this plugin requires:
20+
- the [Angular Recursion](https://github.com/marklagendijk/angular-recursion) module.
21+
- the [Angular directives for Bootstrap](https://github.com/angular-ui/bootstrap) module to display the Calendar (ui.bootstrap.datepicker)
2022

2123
### Installation
2224
First you'll need to download the [dist](https://github.com/dncrews/angular-elastic-builder/tree/master/dist) files and include this JS file to your app (don't forget to substitute `x.x.x` with the current version number), along with the RecursionHelper, if you're not already using it.
2325
```html
24-
<script type="text/javascript" src="/angular-recursion.min.js"></script>
25-
<script type="text/javascript" src="/angular-elastic-builder.min.js"></script>
26+
<script type="text/javascript" src="angular-ui-bootstrap/ui-bootstrap-tpls.js"></script>
27+
<script type="text/javascript" src="angular-recursion/angular-recursion.min.js"></script>
28+
<script type="text/javascript" src="angular-elastic-builder/angular-elastic-builder.min.js"></script>
2629
```
2730

2831
Then make sure that it's included in your app's dependencies during module creation.
@@ -48,10 +51,12 @@ $scope.elasticBuilderData.query = [];
4851
* of data they are
4952
*/
5053
$scope.elasticBuilderData.fields = {
51-
'some.number.field': { type: 'number' },
52-
'some.term.field': { type: 'term' },
53-
'some.boolean.field': { type: 'term', subType: 'boolean' },
54-
'multi.selector': { type: 'multi', choices: [ 'AZ', 'CA', 'CT' ]}
54+
'test.number': { type: 'number', minimum: 650 },
55+
'test.term': { type: 'term' },
56+
'test.boolean': { type: 'term', subType: 'boolean' },
57+
'test.state.multi': { type: 'multi', choices: [ 'AZ', 'CA', 'CT' ]},
58+
'test.date': { type: 'date' },
59+
'test.otherdate': { type: 'date' }
5560
};
5661
```
5762

@@ -61,49 +66,64 @@ $scope.elasticBuilderData.fields = {
6166

6267
The above elasticFields would allow you create the following form:
6368
![Screenshot][screenshot-image]
64-
69+
6570
Which represents the following Elasticsearch Query:
6671
```json
6772
[
6873
{
69-
"terms": {
70-
"multi.selector": [
71-
"AZ",
72-
"CT"
73-
]
74-
}
74+
"and": [
75+
{
76+
"term": {
77+
"test.date": "2016-04-08T10:44:06"
78+
}
79+
},
80+
{
81+
"range": {
82+
"test.number": {
83+
"gte": 650
84+
}
85+
}
86+
},
87+
{
88+
"range": {
89+
"test.number": {
90+
"lt": 850
91+
}
92+
}
93+
}
94+
]
7595
},
7696
{
7797
"term": {
78-
"some.boolean.field": "0"
98+
"test.boolean": 0
99+
}
100+
},
101+
{
102+
"terms": {
103+
"test.state.multi": [ "AZ", "CT" ]
79104
}
80105
},
81106
{
82107
"not": {
83108
"filter": {
84109
"term": {
85-
"some.term.field": "Hello World"
110+
"test.term": "asdfasdf"
86111
}
87112
}
88113
}
89114
},
90115
{
91-
"and": [
92-
{
93-
"range": {
94-
"some.number.field": {
95-
"gte": 0
96-
}
97-
}
98-
},
99-
{
100-
"range": {
101-
"some.number.field": {
102-
"lt": 100
103-
}
104-
}
116+
"exists": {
117+
"field": "test.term"
118+
}
119+
},
120+
{
121+
"range": {
122+
"test.otherdate": {
123+
"gte": "now",
124+
"lte": "now+7d"
105125
}
106-
]
126+
}
107127
}
108128
]
109129
```
@@ -116,6 +136,7 @@ Which represents the following Elasticsearch Query:
116136
- `'term'`: in addition to Generic Options, gets "Equals" and "! Equals"
117137
- `'boolean'`: Does not get Generic Options. Gets `true` and `false`
118138
- These are actually "equals 0" and "equals 1" for the database query
139+
- `'date'`: in addition to Generic Options, gets "&gt;", "&ge;", "&lt;", "&le;", "="
119140

120141
Generic Options
121142
- In addition to any specific options for fields, all fields also get a "Exists" and "! Exists" option
@@ -138,4 +159,5 @@ To work on this module locally, you will need to clone it and run `gulp watch`.
138159
[downloads-url]: https://www.npmjs.org/package/angular-elastic-builder
139160
[gratipay-image]: https://img.shields.io/gratipay/dncrews.svg
140161
[gratipay-url]: https://www.gratipay.com/dncrews/
141-
[screenshot-image]: https://raw.githubusercontent.com/dncrews/angular-elastic-builder/master/screenshot.png
162+
[screenshot-image]: https://cloud.githubusercontent.com/assets/6723310/14424743/c5701566-ffda-11e5-8204-9f4d46c5aec4.png
163+

0 commit comments

Comments
 (0)