diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.html b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.html
index edce0a8a20c7..644ed335e92f 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.html
+++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.html
@@ -113,7 +113,12 @@
data-test-subj="tab-count-{{ editSection.index }}"
aria-label="{{:: editSection.count + ' ' + editSection.title}}"
>
- ({{ editSection.count }})
+
+ ({{ editSection.count }} / {{ editSection.totalCount }})
+
+
+ ({{ editSection.count }})
+
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js
index c3cd781279bd..9fe6df00caa2 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js
+++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js
@@ -58,7 +58,7 @@ function updateSourceFiltersTable($scope, $state) {
filterFilter={$scope.fieldFilter}
fieldWildcardMatcher={$scope.fieldWildcardMatcher}
onAddOrRemoveFilter={() => {
- $scope.editSections = $scope.editSectionsProvider($scope.indexPattern, $scope.indexPatternListProvider);
+ $scope.editSections = $scope.editSectionsProvider($scope.indexPattern, $scope.fieldFilter, $scope.indexPatternListProvider);
$scope.refreshFilters();
$scope.$apply();
}}
@@ -191,7 +191,7 @@ uiModules.get('apps/management')
});
$scope.$watch('indexPattern.fields', function () {
- $scope.editSections = $scope.editSectionsProvider($scope.indexPattern, indexPatternListProvider);
+ $scope.editSections = $scope.editSectionsProvider($scope.indexPattern, $scope.fieldFilter, indexPatternListProvider);
$scope.refreshFilters();
$scope.fields = $scope.indexPattern.getNonScriptedFields();
updateIndexedFieldsTable($scope, $state);
@@ -294,6 +294,7 @@ uiModules.get('apps/management')
};
$scope.$watch('fieldFilter', () => {
+ $scope.editSections = $scope.editSectionsProvider($scope.indexPattern, $scope.fieldFilter, indexPatternListProvider);
if ($scope.fieldFilter === undefined) {
return;
}
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_sections.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_sections.js
index c7f53096bfa6..240418a146a5 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_sections.js
+++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_sections.js
@@ -20,39 +20,59 @@
import _ from 'lodash';
import { i18n } from '@kbn/i18n';
+function filterBy(items, key, filter) {
+ const lowercaseFilter = (filter || '').toLowerCase();
+ return items.filter(item => item[key].toLowerCase().includes(lowercaseFilter));
+}
+
+function getCounts(fields, sourceFilters, fieldFilter = '') {
+ const fieldCount = _.countBy(filterBy(fields, 'name', fieldFilter), function (field) {
+ return field.scripted ? 'scripted' : 'indexed';
+ });
+
+ _.defaults(fieldCount, {
+ indexed: 0,
+ scripted: 0,
+ sourceFilters: sourceFilters ? filterBy(sourceFilters, 'value', fieldFilter).length : 0,
+ });
+
+ return fieldCount;
+}
+
export function IndicesEditSectionsProvider() {
-
- return function (indexPattern, indexPatternListProvider) {
- const fieldCount = _.countBy(indexPattern.fields, function (field) {
- return (field.scripted) ? 'scripted' : 'indexed';
- });
-
- _.defaults(fieldCount, {
- indexed: 0,
- scripted: 0,
- sourceFilters: indexPattern.sourceFilters ? indexPattern.sourceFilters.length : 0,
- });
+ return function (indexPattern, fieldFilter, indexPatternListProvider) {
+ const totalCount = getCounts(indexPattern.fields, indexPattern.sourceFilters);
+ const filteredCount = getCounts(indexPattern.fields, indexPattern.sourceFilters, fieldFilter);
const editSections = [];
editSections.push({
- title: i18n.translate('kbn.management.editIndexPattern.tabs.fieldsHeader', { defaultMessage: 'Fields' }),
+ title: i18n.translate('kbn.management.editIndexPattern.tabs.fieldsHeader', {
+ defaultMessage: 'Fields',
+ }),
index: 'indexedFields',
- count: fieldCount.indexed
+ count: filteredCount.indexed,
+ totalCount: totalCount.indexed,
});
- if(indexPatternListProvider.areScriptedFieldsEnabled(indexPattern)) {
+ if (indexPatternListProvider.areScriptedFieldsEnabled(indexPattern)) {
editSections.push({
- title: i18n.translate('kbn.management.editIndexPattern.tabs.scriptedHeader', { defaultMessage: 'Scripted fields' }),
+ title: i18n.translate('kbn.management.editIndexPattern.tabs.scriptedHeader', {
+ defaultMessage: 'Scripted fields',
+ }),
index: 'scriptedFields',
- count: fieldCount.scripted
+ count: filteredCount.scripted,
+ totalCount: totalCount.scripted,
});
}
editSections.push({
- title: i18n.translate('kbn.management.editIndexPattern.tabs.sourceHeader', { defaultMessage: 'Source filters' }),
+ title: i18n.translate('kbn.management.editIndexPattern.tabs.sourceHeader', {
+ defaultMessage: 'Source filters',
+ }),
index: 'sourceFilters',
- count: fieldCount.sourceFilters
+ count: filteredCount.sourceFilters,
+ totalCount: totalCount.sourceFilters,
});
return editSections;