diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md index 9f3ed8c1263ba..2693e448565fe 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md @@ -7,5 +7,5 @@ Signature: ```typescript -QueryStringInput: React.FC> +React.FC> ``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchsourcefields.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchsourcefields.md index 7a64af0f8b2b8..05d5a23cd0c1f 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchsourcefields.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchsourcefields.md @@ -16,6 +16,7 @@ export interface SearchSourceFields | --- | --- | --- | | [aggs](./kibana-plugin-plugins-data-public.searchsourcefields.aggs.md) | any | | | [fields](./kibana-plugin-plugins-data-public.searchsourcefields.fields.md) | NameList | | +| [fieldsApi](./kibana-plugin-plugins-data-public.searchsourcefields.fieldsapi.md) | NameList | | | [filter](./kibana-plugin-plugins-data-public.searchsourcefields.filter.md) | Filter[] | Filter | (() => Filter[] | Filter | undefined) | | | [from](./kibana-plugin-plugins-data-public.searchsourcefields.from.md) | number | | | [highlight](./kibana-plugin-plugins-data-public.searchsourcefields.highlight.md) | any | | diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index c2cc2fdc3c134..8c10ce2967abd 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -1771,6 +1771,8 @@ export interface SearchSourceFields { // (undocumented) fields?: NameList; // (undocumented) + fieldsApi?: NameList; + // (undocumented) filter?: Filter[] | Filter | (() => Filter[] | Filter | undefined); // (undocumented) from?: number; diff --git a/src/plugins/data/public/search/search_source/search_source.ts b/src/plugins/data/public/search/search_source/search_source.ts index eec2d9b50eafe..f56c3d0b79bd6 100644 --- a/src/plugins/data/public/search/search_source/search_source.ts +++ b/src/plugins/data/public/search/search_source/search_source.ts @@ -381,6 +381,8 @@ export class SearchSource { case 'fields': const fields = uniq((data[key] || []).concat(val)); return addToRoot(key, fields); + case 'fieldsApi': + return key && data[key] == null && addToBody('fields', val); case 'index': case 'type': case 'highlightAll': diff --git a/src/plugins/data/public/search/search_source/types.ts b/src/plugins/data/public/search/search_source/types.ts index c2f8701a64fa3..9c02cfbe6cb7c 100644 --- a/src/plugins/data/public/search/search_source/types.ts +++ b/src/plugins/data/public/search/search_source/types.ts @@ -47,6 +47,7 @@ export interface SearchSourceFields { source?: NameList; version?: boolean; fields?: NameList; + fieldsApi?: NameList; index?: IndexPattern; searchAfter?: EsQuerySearchAfter; timeout?: string; diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 22da3e877054a..7994398a11e92 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -256,7 +256,7 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise $scope.state = { ...newState }; // detect changes that should trigger fetching of new data - const changes = ['interval', 'sort'].filter( + const changes = ['interval', 'sort', 'columns'].filter( (prop) => !_.isEqual(newStatePartial[prop], oldStatePartial[prop]) ); @@ -948,8 +948,14 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise $scope.updateDataSource = () => { const { indexPattern, searchSource } = $scope; + const { docvalueFields } = indexPattern.getComputedFields(); + const columns = $scope.state.columns.filter( + (name) => !docvalueFields.find((docVal) => docVal.field === name) + ); searchSource .setField('index', $scope.indexPattern) + .setField('fieldsApi', columns) + .setField('source', true) .setField('size', $scope.opts.sampleSize) .setField( 'sort', diff --git a/src/plugins/discover/public/application/angular/doc_table/components/table_row.ts b/src/plugins/discover/public/application/angular/doc_table/components/table_row.ts index e7fafde2e68d0..ab8c5cc059aed 100644 --- a/src/plugins/discover/public/application/angular/doc_table/components/table_row.ts +++ b/src/plugins/discover/public/application/angular/doc_table/components/table_row.ts @@ -103,9 +103,12 @@ export function createTableRowDirective($compile: ng.ICompileService, $httpParam $compile($detailsTr)($detailsScope); }; - $scope.$watchMulti(['indexPattern.timeFieldName', 'row.highlight', '[]columns'], () => { - createSummaryRow($scope.row); - }); + $scope.$watchMulti( + ['indexPattern.timeFieldName', 'row.highlight', '[]columns', 'row'], + () => { + createSummaryRow($scope.row); + } + ); $scope.inlineFilter = function inlineFilter($event: any, type: string) { const column = $($event.target).data().column; @@ -174,6 +177,7 @@ export function createTableRowDirective($compile: ng.ICompileService, $httpParam let $cells = $el.children(); newHtmls.forEach(function (html, i) { const $cell = $cells.eq(i); + if ($cell.data('discover:html') === html) return; const reuse = find($cells.slice(i + 1), function (cell: any) {