Skip to content

Commit

Permalink
Include nested fields in the index pattern so we can identify them in…
Browse files Browse the repository at this point in the history
… the Discover UI
  • Loading branch information
Bargs committed Jan 8, 2020
1 parent 64f7c37 commit 7b6ce8d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,11 @@ export function DocViewTable({
const displayNoMappingWarning =
!mapping(field) && !displayUnderscoreWarning && !isArrayOfObjects;

// Nested fields are not a part of the index pattern but their children are.
// Nested children are not a part of the flattened document but their nested parent is.
// So to detect nested fields we look through the index pattern for nested children
// that have the current field in their path. Knowing which fields are nested allows us
// to label them and apply the correct icon in the table row.
const isNestedField = !!indexPattern.fields.find(patternField =>
patternField.subType?.nested?.path.includes(field)
);
const fieldType = isNestedField ? 'nested' : undefined;

return (
<DocViewTableRow
key={field}
field={field}
fieldMapping={mapping(field)}
fieldType={fieldType}
displayUnderscoreWarning={displayUnderscoreWarning}
displayNoMappingWarning={displayNoMappingWarning}
isCollapsed={isCollapsed}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { DocViewTableRowIconUnderscore } from './table_row_icon_underscore';
export interface Props {
field: string;
fieldMapping?: FieldMapping;
fieldType?: string;
displayNoMappingWarning: boolean;
displayUnderscoreWarning: boolean;
isCollapsible: boolean;
Expand All @@ -47,7 +46,6 @@ export interface Props {
export function DocViewTableRow({
field,
fieldMapping,
fieldType,
displayNoMappingWarning,
displayUnderscoreWarning,
isCollapsible,
Expand Down Expand Up @@ -87,7 +85,7 @@ export function DocViewTableRow({
</td>
)}
<td className="kbnDocViewer__field">
<FieldName field={fieldMapping} fieldName={field} fieldType={fieldType} />
<FieldName field={fieldMapping} fieldName={field} />
</td>
<td>
{isCollapsible && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ export function readFieldCapsResponse(fieldCapsResponse: FieldCapsResponse): Fie
});

return kibanaFormattedCaps.filter(field => {
return !['object', 'nested'].includes(field.type);
return !['object'].includes(field.type);
});
}
2 changes: 2 additions & 0 deletions src/plugins/kibana_react/public/field_icon/field_icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface FieldIconProps {
| 'number'
| '_source'
| 'string'
| 'nested'
| string;
label?: string;
size?: IconSize;
Expand All @@ -61,6 +62,7 @@ export const typeToEuiIconMap: Partial<Record<string, IconMapEntry>> = {
number: { icon: 'number', color: colors[0] },
_source: { icon: 'editorCodeBlock', color: colors[3] },
string: { icon: 'string', color: colors[4] },
nested: { icon: 'nested', color: colors[4] },
};

/**
Expand Down

0 comments on commit 7b6ce8d

Please sign in to comment.