@@ -139,4 +139,213 @@ setup:
139
139
140
140
- match : { aggregations.histo.buckets.3.doc_count: 1 }
141
141
142
+ ---
143
+ " date_histogram " :
144
+ - skip :
145
+ version : " - 7.1.99"
146
+ reason : calendar_interval introduced in 7.2.0
147
+
148
+ - do :
149
+ indices.create :
150
+ index : test_2
151
+ body :
152
+ settings :
153
+ # There was a BWC issue that only showed up on empty shards. This
154
+ # test has 4 docs and 5 shards makes sure we get one empty.
155
+ number_of_shards : 5
156
+ mappings :
157
+ properties :
158
+ date :
159
+ type : date
160
+
161
+ - do :
162
+ bulk :
163
+ index : test_2
164
+ refresh : true
165
+ body :
166
+ - ' {"index": {}}'
167
+ - ' {"date": "2016-01-01"}'
168
+ - ' {"index": {}}'
169
+ - ' {"date": "2016-01-02"}'
170
+ - ' {"index": {}}'
171
+ - ' {"date": "2016-02-01"}'
172
+ - ' {"index": {}}'
173
+ - ' {"date": "2016-03-01"}'
174
+
175
+ - do :
176
+ search :
177
+ body :
178
+ size : 0
179
+ aggs :
180
+ histo :
181
+ date_histogram :
182
+ field : date
183
+ calendar_interval : month
184
+
185
+ - match : { hits.total.value: 4 }
186
+ - length : { aggregations.histo.buckets: 3 }
187
+ - match : { aggregations.histo.buckets.0.key_as_string: "2016-01-01T00:00:00.000Z" }
188
+ - match : { aggregations.histo.buckets.0.doc_count: 2 }
189
+ - match : { aggregations.histo.buckets.1.key_as_string: "2016-02-01T00:00:00.000Z" }
190
+ - match : { aggregations.histo.buckets.1.doc_count: 1 }
191
+ - match : { aggregations.histo.buckets.2.key_as_string: "2016-03-01T00:00:00.000Z" }
192
+ - match : { aggregations.histo.buckets.2.doc_count: 1 }
193
+
194
+ ---
195
+ " date_histogram with offset " :
196
+ - skip :
197
+ version : " - 7.1.99"
198
+ reason : calendar_interval introduced in 7.2.0
199
+
200
+ - do :
201
+ indices.create :
202
+ index : test_2
203
+ body :
204
+ settings :
205
+ # There was a BWC issue that only showed up on empty shards. This
206
+ # test has 4 docs and 5 shards makes sure we get one empty.
207
+ number_of_shards : 5
208
+ mappings :
209
+ properties :
210
+ date :
211
+ type : date
212
+
213
+ - do :
214
+ bulk :
215
+ index : test_2
216
+ refresh : true
217
+ body :
218
+ - ' {"index": {}}'
219
+ - ' {"date": "2016-01-01"}'
220
+ - ' {"index": {}}'
221
+ - ' {"date": "2016-01-02"}'
222
+ - ' {"index": {}}'
223
+ - ' {"date": "2016-02-01"}'
224
+ - ' {"index": {}}'
225
+ - ' {"date": "2016-03-01"}'
226
+
227
+ - do :
228
+ search :
229
+ body :
230
+ size : 0
231
+ aggs :
232
+ histo :
233
+ date_histogram :
234
+ field : date
235
+ calendar_interval : month
236
+ offset : +1d
237
+
238
+ - match : { hits.total.value: 4 }
239
+ - length : { aggregations.histo.buckets: 3 }
240
+ - match : { aggregations.histo.buckets.0.key_as_string: "2015-12-02T00:00:00.000Z" }
241
+ - match : { aggregations.histo.buckets.0.doc_count: 1 }
242
+ - match : { aggregations.histo.buckets.1.key_as_string: "2016-01-02T00:00:00.000Z" }
243
+ - match : { aggregations.histo.buckets.1.doc_count: 2 }
244
+ - match : { aggregations.histo.buckets.2.key_as_string: "2016-02-02T00:00:00.000Z" }
245
+ - match : { aggregations.histo.buckets.2.doc_count: 1 }
246
+
142
247
248
+ ---
249
+ " date_histogram on range " :
250
+ - skip :
251
+ version : " - 7.1.99"
252
+ reason : calendar_interval introduced in 7.2.0
253
+
254
+ - do :
255
+ indices.create :
256
+ index : test_2
257
+ body :
258
+ settings :
259
+ # There was a BWC issue that only showed up on empty shards. This
260
+ # test has 4 docs and 5 shards makes sure we get one empty.
261
+ number_of_shards : 5
262
+ mappings :
263
+ properties :
264
+ range :
265
+ type : date_range
266
+
267
+ - do :
268
+ bulk :
269
+ index : test_2
270
+ refresh : true
271
+ body :
272
+ - ' {"index": {}}'
273
+ - ' {"range": {"gte": "2016-01-01", "lt": "2016-01-02"}}'
274
+ - ' {"index": {}}'
275
+ - ' {"range": {"gte": "2016-01-02", "lt": "2016-01-03"}}'
276
+ - ' {"index": {}}'
277
+ - ' {"range": {"gte": "2016-02-01", "lt": "2016-02-02"}}'
278
+ - ' {"index": {}}'
279
+ - ' {"range": {"gte": "2016-03-01", "lt": "2016-03-02"}}'
280
+
281
+ - do :
282
+ search :
283
+ body :
284
+ size : 0
285
+ aggs :
286
+ histo :
287
+ date_histogram :
288
+ field : range
289
+ calendar_interval : month
290
+
291
+ - match : { hits.total.value: 4 }
292
+ - length : { aggregations.histo.buckets: 3 }
293
+ - match : { aggregations.histo.buckets.0.key_as_string: "2016-01-01T00:00:00.000Z" }
294
+ - match : { aggregations.histo.buckets.0.doc_count: 2 }
295
+ - match : { aggregations.histo.buckets.1.key_as_string: "2016-02-01T00:00:00.000Z" }
296
+ - match : { aggregations.histo.buckets.1.doc_count: 1 }
297
+ - match : { aggregations.histo.buckets.2.key_as_string: "2016-03-01T00:00:00.000Z" }
298
+ - match : { aggregations.histo.buckets.2.doc_count: 1 }
299
+
300
+ ---
301
+ " date_histogram on range with offset " :
302
+ - skip :
303
+ version : " - 7.1.99"
304
+ reason : calendar_interval introduced in 7.2.0
305
+
306
+ - do :
307
+ indices.create :
308
+ index : test_2
309
+ body :
310
+ settings :
311
+ # There was a BWC issue that only showed up on empty shards. This
312
+ # test has 4 docs and 5 shards makes sure we get one empty.
313
+ number_of_shards : 5
314
+ mappings :
315
+ properties :
316
+ range :
317
+ type : date_range
318
+
319
+ - do :
320
+ bulk :
321
+ index : test_2
322
+ refresh : true
323
+ body :
324
+ - ' {"index": {}}'
325
+ - ' {"range": {"gte": "2016-01-01", "lt": "2016-01-02"}}'
326
+ - ' {"index": {}}'
327
+ - ' {"range": {"gte": "2016-01-02", "lt": "2016-01-03"}}'
328
+ - ' {"index": {}}'
329
+ - ' {"range": {"gte": "2016-02-01", "lt": "2016-02-02"}}'
330
+ - ' {"index": {}}'
331
+ - ' {"range": {"gte": "2016-03-01", "lt": "2016-03-02"}}'
332
+
333
+ - do :
334
+ search :
335
+ body :
336
+ size : 0
337
+ aggs :
338
+ histo :
339
+ date_histogram :
340
+ field : range
341
+ calendar_interval : month
342
+ offset : +1d
343
+
344
+ - match : { hits.total.value: 4 }
345
+ - length : { aggregations.histo.buckets: 3 }
346
+ - match : { aggregations.histo.buckets.0.key_as_string: "2015-12-02T00:00:00.000Z" }
347
+ - match : { aggregations.histo.buckets.0.doc_count: 1 }
348
+ - match : { aggregations.histo.buckets.1.key_as_string: "2016-01-02T00:00:00.000Z" }
349
+ - match : { aggregations.histo.buckets.1.doc_count: 2 }
350
+ - match : { aggregations.histo.buckets.2.key_as_string: "2016-02-02T00:00:00.000Z" }
351
+ - match : { aggregations.histo.buckets.2.doc_count: 1 }
0 commit comments