Skip to content

Commit

Permalink
Support range filters
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Li <joshuali925@gmail.com>
  • Loading branch information
joshuali925 committed Oct 19, 2021
1 parent 82b2789 commit 6331696
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions dashboards-reports/server/routes/utils/dataReportHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
* permissions and limitations under the License.
*/

import { DATA_REPORT_CONFIG } from './constants';

import esb, { Sort } from 'elastic-builder';
import moment from 'moment';
import converter from 'json-2-csv';
import _ from 'lodash';
import moment from 'moment';
import { DATA_REPORT_CONFIG } from './constants';

export var metaData = {
saved_search_id: <string>null,
Expand Down Expand Up @@ -92,6 +91,14 @@ export const buildQuery = (report, is_count) => {
}
requestBody.minimumShouldMatch(1);
break;
case 'range':
const builder = esb.rangeQuery(item.meta.key);
if (item.meta.params.gte) builder.gte(item.meta.params.gte);
if (item.meta.params.lte) builder.lte(item.meta.params.lte);
if (item.meta.params.gt) builder.gt(item.meta.params.gt);
if (item.meta.params.lt) builder.lt(item.meta.params.lt);
requestBody.must(builder);
break;
}
break;
case true:
Expand Down Expand Up @@ -119,6 +126,14 @@ export const buildQuery = (report, is_count) => {
negatedBody.minimumShouldMatch(1);
requestBody.mustNot(negatedBody);
break;
case 'range':
const builder = esb.rangeQuery(item.meta.key);
if (item.meta.params.gte) builder.gte(item.meta.params.gte);
if (item.meta.params.lte) builder.lte(item.meta.params.lte);
if (item.meta.params.gt) builder.gt(item.meta.params.gt);
if (item.meta.params.lt) builder.lt(item.meta.params.lt);
requestBody.mustNot(builder);
break;
}
break;
}
Expand Down

0 comments on commit 6331696

Please sign in to comment.