Skip to content

Commit

Permalink
simplified condition
Browse files Browse the repository at this point in the history
  • Loading branch information
scampi committed Dec 28, 2016
1 parent 1bd4727 commit 5babf9a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/ui/public/index_patterns/_flatten_hit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ export default function FlattenHitProvider(config) {
_.forOwn(obj, function (val, key) {
key = keyPrefix + key;

if (!deep && flat[key] !== void 0) {
return;
}

if (deep) {
const isNestedField = fields[key] && fields[key].type === 'nested';
const isArrayOfObjects = _.isArray(val) && _.isPlainObject(_.first(val));
if (isArrayOfObjects && !isNestedField) {
_.each(val, v => flatten(v, key));
return;
}
} else if (flat[key] !== void 0) {
return;
}

const hasValidMapping = fields[key] && fields[key].type !== 'conflict';
Expand Down Expand Up @@ -70,4 +68,4 @@ export default function FlattenHitProvider(config) {
return hit.$$_flattened || (hit.$$_flattened = flattenHit(indexPattern, hit, deep));
};
};
};
}

0 comments on commit 5babf9a

Please sign in to comment.