diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 7ce53a219fb44..075a0d316de0d 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -2039,6 +2039,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 4afee223454e4..8f98f50a9582c 100644 --- a/src/plugins/data/public/search/search_source/search_source.ts +++ b/src/plugins/data/public/search/search_source/search_source.ts @@ -403,6 +403,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/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 7871cc4b16464..390e30b53ea2f 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -255,7 +255,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]) ); @@ -863,7 +863,9 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise } $scope.hits = resp.hits.total; - $scope.rows = resp.hits.hits; + $scope.rows = resp.hits.hits.map((hit) => { + return { ...hit, ...{ _source: hit.fields } }; + }); // if we haven't counted yet, reset the counts const counts = ($scope.fieldCounts = $scope.fieldCounts || {}); @@ -940,6 +942,8 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise const { indexPattern, searchSource } = $scope; searchSource .setField('index', $scope.indexPattern) + .setField('fieldsApi', ['*']) + .setField('source', false) .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) {