From 23fdcd850c19ac5f468a14d6b9856d0f1459ddaf Mon Sep 17 00:00:00 2001
From: Divyanshu Maithani
Date: Fri, 14 Sep 2018 16:24:39 +0530
Subject: [PATCH] :bug: Fix #232 has filter
---
live/src/js/table/Column.js | 2 +-
live/src/js/table/FilterDropdown.js | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/live/src/js/table/Column.js b/live/src/js/table/Column.js
index b021b4e0..a30ad50d 100644
--- a/live/src/js/table/Column.js
+++ b/live/src/js/table/Column.js
@@ -165,7 +165,7 @@ class Column extends React.Component {
;
const filterRow = this.props.externalQueryApplied ? '' : (
-
+
);
// const handleSort = this.sortingInit;
diff --git a/live/src/js/table/FilterDropdown.js b/live/src/js/table/FilterDropdown.js
index 7d083734..3900cc30 100644
--- a/live/src/js/table/FilterDropdown.js
+++ b/live/src/js/table/FilterDropdown.js
@@ -31,8 +31,23 @@ class FilterDropdown extends React.Component {
};
applyFilter = () => {
+ const { mappingObj, type, datatype } = this.props;
+ const mappingFields = mappingObj[type].properties;
if (this.state.filterField != null && this.state.filterValue != null && this.state.filterValue != '') {
- this.props.filterInfo.applyFilter(this.props.type, this.props.columnField, this.state.filterField, this.state.filterValue, this.state.filterField === 'has' || this.state.filterField === 'has not' ? false : this.props.analyzed);
+ let colField = this.props.columnField;
+ if (datatype === 'string' || datatype === 'keyword' || datatype === 'text') {
+ const currentMapping = mappingFields[colField];
+ if (currentMapping.index !== 'not_analyzed') {
+ const currentFields = currentMapping.fields;
+ if (currentFields) {
+ const suffix = Object.keys(currentFields).find(key => currentFields[key].type === 'keyword' || currentFields[key].index === 'not_analyzed');
+ if (suffix) {
+ colField += `.${suffix}`;
+ }
+ }
+ }
+ }
+ this.props.filterInfo.applyFilter(this.props.type, colField, this.state.filterField, this.state.filterValue, this.state.filterField === 'has' || this.state.filterField === 'has not' ? false : this.props.analyzed);
document.body.click();
}
};