Use correct time range for index constraints

The existing index constraints would only work when all of the documents
in an index fell within the given time range. This change ensures that
indexes are returned if ANY document falls within the given time range.
This commit is contained in:
Court Ewing 2015-11-03 13:11:06 -05:00
parent df0fe171b3
commit 65c5053b99
2 changed files with 10 additions and 10 deletions

View file

@ -50,21 +50,21 @@ describe('ui/index_patterns/_calculate_indices', () => {
context('when given start', () => {
beforeEach(() => run({ start: '1234567890' }));
it('includes min_value', () => {
expect(constraints['@something']).to.have.property('min_value');
it('includes max_value', () => {
expect(constraints['@something']).to.have.property('max_value');
});
it('min_value is gte', () => {
expect(constraints['@something'].min_value).to.have.property('gte');
it('max_value is gte', () => {
expect(constraints['@something'].max_value).to.have.property('gte');
});
});
context('when given stop', () => {
beforeEach(() => run({ stop: '1234567890' }));
it('includes max_value', () => {
expect(constraints['@something']).to.have.property('max_value');
it('includes min_value', () => {
expect(constraints['@something']).to.have.property('min_value');
});
it('max_value is lt', () => {
expect(constraints['@something'].max_value).to.have.property('lt');
it('min_value is lte', () => {
expect(constraints['@something'].min_value).to.have.property('lte');
});
});
});

View file

@ -17,10 +17,10 @@ define(function (require) {
function compileOptions(pattern, timeFieldName, start, stop) {
const constraints = {};
if (start) {
constraints.min_value = { gte: moment(start).valueOf() };
constraints.max_value = { gte: moment(start).valueOf() };
}
if (stop) {
constraints.max_value = { lt: moment(stop).valueOf() };
constraints.min_value = { lte: moment(stop).valueOf() };
}
return {