Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Show Alias Fields in Discover Tab #7930

Merged
merged 9 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_USE_FIELDS: 'search:useFields',
HISTOGRAM_BAR_TARGET: 'histogram:barTarget',
HISTOGRAM_MAX_BARS: 'histogram:maxBars',
HISTORY_LIMIT: 'history:limit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
UI_SETTINGS.SEARCH_INCLUDE_FROZEN,
UI_SETTINGS.SORT_OPTIONS,
UI_SETTINGS.QUERY_DATAFRAME_HYDRATION_STRATEGY,
UI_SETTINGS.SEARCH_USE_FIELDS,
];

export interface SearchSourceDependencies extends FetchHandlers {
Expand Down Expand Up @@ -582,6 +583,7 @@

flatten() {
const searchRequest = this.mergeProps();
const { getConfig } = this.dependencies;

Check warning on line 586 in src/plugins/data/common/search/search_source/search_source.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/common/search/search_source/search_source.ts#L586

Added line #L586 was not covered by tests

searchRequest.body = searchRequest.body || {};
const { body, index, fields, query, filters, highlightAll } = searchRequest;
Expand All @@ -591,6 +593,9 @@

body.stored_fields = computedFields.storedFields;
body.script_fields = body.script_fields || {};
if (getConfig(UI_SETTINGS.SEARCH_USE_FIELDS)) {
body.fields = ['*'];

Check warning on line 597 in src/plugins/data/common/search/search_source/search_source.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/common/search/search_source/search_source.ts#L597

Added line #L597 was not covered by tests
}
extend(body.script_fields, computedFields.scriptFields);

const defaultDocValueFields = computedFields.docvalueFields
Expand All @@ -602,8 +607,6 @@
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_USE_FIELDS]: {
name: i18n.translate('data.advancedSettings.searchUseFieldsTitle', {
defaultMessage: 'Include all fields in search request',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this setting is to include all fields, would search:includeAllFields be better than search:useFields?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that previously, we weren't using the fields field in the request body. Turning on this property "uses" fields. I think in this case, the title itself could be something different.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this suggestion

}),
value: false,
description: i18n.translate('data.advancedSettings.searchUseFieldsDescription', {
defaultMessage: `
<strong>Experimental</strong>:
Adds the <code>"fields": ["*"]</code> property to search request body`,
}),
schema: schema.boolean(),
category: ['search'],
},
};
}
Loading