Skip to content

Commit

Permalink
[Fix] Show Alias Fields in Discover Tab (#7930)
Browse files Browse the repository at this point in the history
* Add field search option

Signed-off-by: Suchit Sahoo <[email protected]>

* initial implementation for new setting

Signed-off-by: Sean Li <[email protected]>

* Changeset file for PR #7930 created/updated

* update naming

Signed-off-by: Sean Li <[email protected]>

* removing page reload

Signed-off-by: Sean Li <[email protected]>

* updating names

Signed-off-by: Sean Li <[email protected]>

---------

Signed-off-by: Suchit Sahoo <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Co-authored-by: Suchit Sahoo <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 5, 2024
1 parent 06816d5 commit 0c047dc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7930.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Show alias fields in Discover tab ([#7930](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7930))
1 change: 1 addition & 0 deletions src/plugins/data/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/data/common/search/search_source/search_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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));
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/data/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,5 +762,18 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
}),
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: `
<strong>Experimental</strong>:
Adds the <code>"fields": ["*"]</code> property to search request body`,
}),
schema: schema.boolean(),
category: ['search'],
},
};
}

0 comments on commit 0c047dc

Please sign in to comment.