mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Backport PR #7990
--------- **Commit 1:** Add indicies and type information for conflict field Fixes #7661 Added indicies and type information when hover over field with conflict type in index patterns page. * Original sha:f842f65faf
* Authored by Martin Hickey <martin.hickey@ie.ibm.com> on 2016-08-12T12:35:01Z **Commit 2:** Update to display the conflict information on the edit field page Fixes #7661 Moved content to the edit field page from the tooltip for better scalability when large data. The conflict description data is now only stored for conflicting fields. * Original sha:0af13831d5
* Authored by Martin Hickey <martin.hickey@ie.ibm.com> on 2016-09-08T16:15:19Z **Commit 3:** Update the conflict data to show all index names per type Fixes #7661 Feedback from review is that it would be better to display a list of indices for each field type as would be easier to distinguish the outliers in this case. * Original sha:ee698c4f0b
* Authored by Martin Hickey <martin.hickey@ie.ibm.com> on 2016-09-16T15:14:57Z **Commit 4:** Update the alert to a warning icon Fixes #7661 Feedback in review as follows: For such a large section, I think just displaying a warning icon near the top of the section would be fine instead of wrapping the entire block in an alert class. * Original sha:8be70d4c61
* Authored by Martin Hickey <martin.hickey@ie.ibm.com> on 2016-09-19T09:37:14Z **Commit 5:** Move the warning message to near end of the page Fixes #7661 * Original sha:14e9bb6c72
* Authored by Martin Hickey <martin.hickey@ie.ibm.com> on 2016-09-20T16:12:45Z **Commit 6:** [indexPatterns/field] show the conflict indices as a list, not JSON * Original sha:4c96efb6c6
* Authored by spalger <email@spalger.com> on 2016-10-13T03:38:15Z * Committed by Martin Hickey <martin.hickey@ie.ibm.com> on 2016-10-13T10:12:29Z **Commit 7:** [indexPatterns/mapping] extract conflict-describing logic * Original sha:a71dd2c22b
* Authored by spalger <email@spalger.com> on 2016-10-13T03:40:06Z * Committed by Martin Hickey <martin.hickey@ie.ibm.com> on 2016-10-13T10:13:46Z
This commit is contained in:
parent
3ff01f2057
commit
a407c7e8c5
5 changed files with 68 additions and 4 deletions
|
@ -177,6 +177,25 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div ng-if="editor.conflictDescriptionsLength > 0">
|
||||
<p>
|
||||
<i class="fa fa-warning text-warning"></i>
|
||||
<strong>Field Type Conflict:</strong>
|
||||
The type of this field changes across indices. It is unavailable for many analysis functions. The indices per type are as follows:
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th> Field Type </th>
|
||||
<th> Index Names </th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="(type, indices) in editor.field.conflictDescriptions">
|
||||
<td>{{type}}</td> <td>{{indices.join(', ')}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<button
|
||||
type="button"
|
||||
|
|
|
@ -46,6 +46,7 @@ uiModules
|
|||
self.indexPattern = $scope.getIndexPattern();
|
||||
self.field = shadowCopy($scope.getField());
|
||||
self.formatParams = self.field.format.params();
|
||||
self.conflictDescriptionsLength = (self.field.conflictDescriptions) ? Object.keys(self.field.conflictDescriptions).length : 0;
|
||||
|
||||
// only init on first create
|
||||
self.creating = !self.indexPattern.fields.byName[self.field.name];
|
||||
|
|
29
src/ui/public/index_patterns/_conflict_tracker.js
Normal file
29
src/ui/public/index_patterns/_conflict_tracker.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { uniq, where, groupBy, mapValues, pluck } from 'lodash';
|
||||
|
||||
export class ConflictTracker {
|
||||
constructor() {
|
||||
this._history = [];
|
||||
}
|
||||
|
||||
trackField(name, type, index) {
|
||||
this._history.push({ name, type, index });
|
||||
}
|
||||
|
||||
describeConflict(name) {
|
||||
const fieldHistory = where(this._history, { name });
|
||||
const entriesByType = groupBy(fieldHistory, 'type');
|
||||
|
||||
return mapValues(entriesByType, (entries) => {
|
||||
const indices = uniq(pluck(entries, 'index'));
|
||||
|
||||
// keep the list short so we don't polute the .kibana index
|
||||
if (indices.length > 10) {
|
||||
const total = indices.length;
|
||||
indices.length = 9;
|
||||
indices.push(`... and ${total - indices.length} others`);
|
||||
}
|
||||
|
||||
return indices;
|
||||
});
|
||||
}
|
||||
};
|
|
@ -71,6 +71,9 @@ export default function FieldObjectProvider(Private, shortDotsFilter, $rootScope
|
|||
obj.comp('displayName', shortDotsFilter(spec.name));
|
||||
obj.comp('$$spec', spec);
|
||||
|
||||
// conflict info
|
||||
obj.writ('conflictDescriptions');
|
||||
|
||||
return obj.create();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import _ from 'lodash';
|
||||
import IndexPatternsMapFieldProvider from 'ui/index_patterns/_map_field';
|
||||
import { ConflictTracker } from 'ui/index_patterns/_conflict_tracker';
|
||||
|
||||
export default function transformMappingIntoFields(Private, kbnIndex, config) {
|
||||
let mapField = Private(IndexPatternsMapFieldProvider);
|
||||
|
||||
|
||||
/**
|
||||
* Convert the ES response into the simple map for fields to
|
||||
* mappings which we will cache
|
||||
|
@ -15,6 +16,8 @@ export default function transformMappingIntoFields(Private, kbnIndex, config) {
|
|||
*/
|
||||
return function (response) {
|
||||
let fields = {};
|
||||
const conflictTracker = new ConflictTracker();
|
||||
|
||||
_.each(response, function (index, indexName) {
|
||||
if (indexName === kbnIndex) return;
|
||||
_.each(index.mappings, function (mappings) {
|
||||
|
@ -23,15 +26,19 @@ export default function transformMappingIntoFields(Private, kbnIndex, config) {
|
|||
if (keys.length === 0 || (name[0] === '_') && !_.contains(config.get('metaFields'), name)) return;
|
||||
|
||||
let mapping = mapField(field, name);
|
||||
// track the name, type and index for every field encountered so that the source
|
||||
// of conflicts can be described later
|
||||
conflictTracker.trackField(name, mapping.type, indexName);
|
||||
|
||||
if (fields[name]) {
|
||||
if (fields[name].type !== mapping.type) {
|
||||
// conflict fields are not available for much except showing in the discover table
|
||||
mapping.type = 'conflict';
|
||||
mapping.indexed = false;
|
||||
// overwrite the entire mapping object to reset all fields
|
||||
fields[name] = { type: 'conflict' };
|
||||
}
|
||||
} else {
|
||||
fields[name] = _.pick(mapping, 'type', 'indexed', 'analyzed', 'doc_values');
|
||||
}
|
||||
fields[name] = _.pick(mapping, 'type', 'indexed', 'analyzed', 'doc_values');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -46,6 +53,11 @@ export default function transformMappingIntoFields(Private, kbnIndex, config) {
|
|||
|
||||
return _.map(fields, function (mapping, name) {
|
||||
mapping.name = name;
|
||||
|
||||
if (mapping.type === 'conflict') {
|
||||
mapping.conflictDescriptions = conflictTracker.describeConflict(name);
|
||||
}
|
||||
|
||||
return mapping;
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue