From 4bc1938966bfa20ceed4e7482fdbec06530e58d2 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 6 Jul 2021 12:01:01 +0100 Subject: [PATCH] Fix data provider filtering on datetime fields --- packages/standard-components/src/lucene.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/standard-components/src/lucene.js b/packages/standard-components/src/lucene.js index 8cbd1ea0fe..91c69dfda2 100644 --- a/packages/standard-components/src/lucene.js +++ b/packages/standard-components/src/lucene.js @@ -13,9 +13,12 @@ export const buildLuceneQuery = filter => { notEmpty: {}, } if (Array.isArray(filter)) { - // Build up proper range filters filter.forEach(expression => { - const { operator, field, type, value } = expression + let { operator, field, type, value } = expression + // Ensure date fields are transformed into ISO strings + if (type === "datetime" && value) { + value = new Date(value).toISOString() + } if (operator.startsWith("range")) { if (!query.range[field]) { query.range[field] = {