diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx index 6f032ecc9a580..f3a3f121e36ad 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx @@ -202,7 +202,18 @@ export function DiscoverSidebarComponent({ if (Array.isArray(fields)) { for (const field of fields) { if (field.type !== '_source') { - dataViewFieldTypes.add(field.type); + // If it's a string type, we want to distinguish between keyword and text + // For this purpose we need the ES type + const type = + field.type === 'string' && + field.esTypes && + ['keyword', 'text'].includes(field.esTypes[0]) + ? field.esTypes?.[0] + : field.type; + // _id and _index would map to string, that's why we don't add the string type here + if (type && type !== 'string') { + dataViewFieldTypes.add(type); + } if (result.indexOf(field.type) === -1) { result.push(field.type); }