From 59da1e30b1fdf6e574e770bd7fa554337ae7cb0b Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:29:18 -0700 Subject: [PATCH] [Fix] Show Alias Fields in Discover Tab (#7930) (#8030) * Add field search option * initial implementation for new setting * Changeset file for PR #7930 created/updated * update naming * removing page reload * updating names --------- (cherry picked from commit 0c047dc390cdfd4a4e01b9d3f01ef2b830ce9a03) Signed-off-by: Suchit Sahoo Signed-off-by: Sean Li Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] Co-authored-by: Suchit Sahoo Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> --- changelogs/fragments/7930.yml | 2 ++ src/plugins/data/common/constants.ts | 1 + .../common/search/search_source/search_source.ts | 7 +++++-- src/plugins/data/server/ui_settings.ts | 13 +++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/7930.yml diff --git a/changelogs/fragments/7930.yml b/changelogs/fragments/7930.yml new file mode 100644 index 000000000000..ce3a0c638262 --- /dev/null +++ b/changelogs/fragments/7930.yml @@ -0,0 +1,2 @@ +fix: +- Show alias fields in Discover tab ([#7930](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7930)) \ No newline at end of file diff --git a/src/plugins/data/common/constants.ts b/src/plugins/data/common/constants.ts index 289d56d4d064..199391630b25 100644 --- a/src/plugins/data/common/constants.ts +++ b/src/plugins/data/common/constants.ts @@ -86,6 +86,7 @@ export const UI_SETTINGS = { COURIER_BATCH_SEARCHES: 'courier:batchSearches', SEARCH_INCLUDE_FROZEN: 'search:includeFrozen', SEARCH_TIMEOUT: 'search:timeout', + SEARCH_INCLUDE_ALL_FIELDS: 'search:includeAllFields', HISTOGRAM_BAR_TARGET: 'histogram:barTarget', HISTOGRAM_MAX_BARS: 'histogram:maxBars', HISTORY_LIMIT: 'history:limit', diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts index c8eb99b038a7..6a2eee0162b5 100644 --- a/src/plugins/data/common/search/search_source/search_source.ts +++ b/src/plugins/data/common/search/search_source/search_source.ts @@ -131,6 +131,7 @@ export const searchSourceRequiredUiSettings = [ UI_SETTINGS.SEARCH_INCLUDE_FROZEN, UI_SETTINGS.SORT_OPTIONS, UI_SETTINGS.QUERY_DATAFRAME_HYDRATION_STRATEGY, + UI_SETTINGS.SEARCH_INCLUDE_ALL_FIELDS, ]; export interface SearchSourceDependencies extends FetchHandlers { @@ -586,6 +587,7 @@ export class SearchSource { flatten() { const searchRequest = this.mergeProps(); + const { getConfig } = this.dependencies; searchRequest.body = searchRequest.body || {}; const { body, index, fields, query, filters, highlightAll } = searchRequest; @@ -595,6 +597,9 @@ export class SearchSource { body.stored_fields = computedFields.storedFields; body.script_fields = body.script_fields || {}; + if (getConfig(UI_SETTINGS.SEARCH_INCLUDE_ALL_FIELDS)) { + body.fields = ['*']; + } extend(body.script_fields, computedFields.scriptFields); const defaultDocValueFields = computedFields.docvalueFields @@ -606,8 +611,6 @@ export class SearchSource { body._source = index.getSourceFiltering(); } - const { getConfig } = this.dependencies; - if (body._source) { // exclude source fields for this index pattern specified by the user const filter = fieldWildcardFilter(body._source.excludes, getConfig(UI_SETTINGS.META_FIELDS)); diff --git a/src/plugins/data/server/ui_settings.ts b/src/plugins/data/server/ui_settings.ts index 79cf50a900b9..4cee0a9894dd 100644 --- a/src/plugins/data/server/ui_settings.ts +++ b/src/plugins/data/server/ui_settings.ts @@ -762,5 +762,18 @@ export function getUiSettings(): Record> { }), schema: schema.arrayOf(schema.string()), }, + [UI_SETTINGS.SEARCH_INCLUDE_ALL_FIELDS]: { + name: i18n.translate('data.advancedSettings.searchIncludeAllFieldsTitle', { + defaultMessage: 'Include all fields in search request', + }), + value: false, + description: i18n.translate('data.advancedSettings.searchIncludeAllFieldsText', { + defaultMessage: ` + Experimental: + Adds the "fields": ["*"] property to search request body`, + }), + schema: schema.boolean(), + category: ['search'], + }, }; }