From 1330f20fcaf78908b016bfe385fc4ddc39381532 Mon Sep 17 00:00:00 2001 From: Zuocheng Ding Date: Tue, 2 Nov 2021 23:39:21 +0000 Subject: [PATCH] Add new verioned document links Fix the Query DQL linking bug: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/769 Signed-off-by: Zuocheng Ding --- src/core/public/chrome/chrome_service.tsx | 2 +- .../doc_links/doc_links_service.test.ts | 4 +- .../public/doc_links/doc_links_service.ts | 114 +++++++++++++++++- .../json/generated/msearch.json | 2 +- .../json/generated/msearch_template.json | 2 +- .../application/help_menu/help_menu_util.ts | 4 +- .../kuery/node_types/wildcard.ts | 2 +- .../query_string_input/language_switcher.tsx | 2 +- .../query_string_input/query_bar_top_row.tsx | 2 +- .../query_string_input/query_string_input.tsx | 2 +- .../autocomplete/value_suggestions_route.ts | 4 +- .../doc/use_opensearch_doc_search.ts | 2 +- .../components/help_menu/help_menu_util.js | 4 +- .../public/control/list_control_factory.ts | 2 +- 14 files changed, 128 insertions(+), 20 deletions(-) diff --git a/src/core/public/chrome/chrome_service.tsx b/src/core/public/chrome/chrome_service.tsx index 93747ee2501e..57230482eda8 100644 --- a/src/core/public/chrome/chrome_service.tsx +++ b/src/core/public/chrome/chrome_service.tsx @@ -239,7 +239,7 @@ export class ChromeService { basePath={http.basePath} breadcrumbs$={breadcrumbs$.pipe(takeUntil(this.stop$))} customNavLink$={customNavLink$.pipe(takeUntil(this.stop$))} - opensearchDashboardsDocLink={docLinks.links.opensearchDashboards} + opensearchDashboardsDocLink={docLinks.links.opensearchDashboards.introduction} forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()} helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))} helpSupportUrl$={helpSupportUrl$.pipe(takeUntil(this.stop$))} diff --git a/src/core/public/doc_links/doc_links_service.test.ts b/src/core/public/doc_links/doc_links_service.test.ts index eae81c96f18b..c74acda88d4c 100644 --- a/src/core/public/doc_links/doc_links_service.test.ts +++ b/src/core/public/doc_links/doc_links_service.test.ts @@ -40,6 +40,8 @@ describe('DocLinksService#start()', () => { const service = new DocLinksService(); const api = service.start({ injectedMetadata }); expect(api.DOC_LINK_VERSION).toEqual('test-branch'); - expect(api.links.opensearchDashboards).toEqual('https://opensearch.org/docs/dashboards/'); + expect(api.links.opensearchDashboards.introduction).toEqual( + 'https://www.opensearch.org/docs/test-branch/dashboards/index' + ); }); }); diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts index e29c34aa55a9..eb661c955f5b 100644 --- a/src/core/public/doc_links/doc_links_service.ts +++ b/src/core/public/doc_links/doc_links_service.ts @@ -46,10 +46,84 @@ export class DocLinksService { const OPENSEARCH_DOCS = `https://opensearch.org/docs/opensearch/`; const OPENSEARCH_DASHBOARDS_DOCS = `https://opensearch.org/docs/dashboards/`; + const OPENSEARCH_VERSIONED_DOCS = + OPENSEARCH_WEBSITE_URL + `docs/` + DOC_LINK_VERSION + `/opensearch/`; + const OPENSEARCH_DASHBOARDS_VERSIONED_DOCS = + OPENSEARCH_WEBSITE_URL + `docs/` + DOC_LINK_VERSION + `/dashboards/`; + return deepFreeze({ DOC_LINK_VERSION, OPENSEARCH_WEBSITE_URL, links: { + opensearch: { + // https://opensearch.org/docs/latest/opensearch/index/ + introduction: `${OPENSEARCH_VERSIONED_DOCS}index`, + // https://opensearch.org/docs/latest/opensearch/install/index/ + installation: `${OPENSEARCH_VERSIONED_DOCS}install/index`, + // https://opensearch.org/docs/latest/opensearch/configuration/ + configuration: `${OPENSEARCH_VERSIONED_DOCS}configuration`, + // https://opensearch.org/docs/latest/opensearch/cluster/ + cluster: `${OPENSEARCH_VERSIONED_DOCS}cluster`, + // https://opensearch.org/docs/latest/opensearch/index-data/ + indexData: `${OPENSEARCH_VERSIONED_DOCS}index-data`, + // https://opensearch.org/docs/latest/opensearch/index-alias/ + indexAlias: `${OPENSEARCH_VERSIONED_DOCS}index-alias`, + // https://opensearch.org/docs/latest/opensearch/data-streams/ + dataStreams: `${OPENSEARCH_VERSIONED_DOCS}data-streams`, + // https://opensearch.org/docs/latest/opensearch/aggregations/ + aggregations: { + // https://opensearch.org/docs/latest/opensearch/metric-agg/ + matric: `${OPENSEARCH_VERSIONED_DOCS}metric-agg`, + // https://opensearch.org/docs/latest/opensearch/bucket-agg/ + bucket: `${OPENSEARCH_VERSIONED_DOCS}bucket-agg`, + // https://opensearch.org/docs/latest/opensearch/pipeline-agg/ + pipeline: `${OPENSEARCH_VERSIONED_DOCS}pipeline-agg`, + }, + // https://opensearch.org/docs/latest/opensearch/index-templates/ + indexTemplates: `${OPENSEARCH_VERSIONED_DOCS}/index-templates`, + // https://opensearch.org/docs/latest/opensearch/reindex-data/ + reindexData: `${OPENSEARCH_VERSIONED_DOCS}/reindex-data`, + queryDSL: { + // https://opensearch.org/docs/latest/opensearch/query-dsl/index/ + introduction: `${OPENSEARCH_VERSIONED_DOCS}query-dsl/index`, + // https://opensearch.org/docs/latest/opensearch/query-dsl/term/ + term: `${OPENSEARCH_VERSIONED_DOCS}query-dsl/term`, + // https://opensearch.org/docs/latest/opensearch/query-dsl/full-text/ + fullText: `${OPENSEARCH_VERSIONED_DOCS}query-dsl/full-text`, + // https://opensearch.org/docs/latest/opensearch/query-dsl/bool/ + boolQuery: `${OPENSEARCH_VERSIONED_DOCS}query-dsl/bool`, + }, + // https://opensearch.org/docs/latest/opensearch/search-template/ + searchTemplate: `${OPENSEARCH_VERSIONED_DOCS}/search-template`, + // https://opensearch.org/docs/latest/opensearch/ux/ + searchExperience: `${OPENSEARCH_VERSIONED_DOCS}/ux`, + // https://opensearch.org/docs/latest/opensearch/logs/ + logs: `${OPENSEARCH_VERSIONED_DOCS}/logs`, + // https://opensearch.org/docs/latest/opensearch/snapshot-restore/ + snapshotRestore: `${OPENSEARCH_VERSIONED_DOCS}/snapshot-restore`, + // https://opensearch.org/docs/latest/opensearch/units/ + supportedUnits: `${OPENSEARCH_VERSIONED_DOCS}/units`, + // https://opensearch.org/docs/latest/opensearch/common-parameters/ + commonParameters: `${OPENSEARCH_VERSIONED_DOCS}/common-parameters`, + // https://opensearch.org/docs/latest/opensearch/popular-api/ + popularAPI: `${OPENSEARCH_VERSIONED_DOCS}/popular-api`, + }, + opensearchDashboards: { + // https://opensearch.org/docs/latest/dashboards/index/ + introduction: `${OPENSEARCH_DASHBOARDS_VERSIONED_DOCS}index`, + // https://opensearch.org/docs/latest/dashboards/install/index/ + installation: `${OPENSEARCH_DASHBOARDS_VERSIONED_DOCS}install/index`, + // https://opensearch.org/docs/latest/dashboards/maptiles/ + mapTiles: `${OPENSEARCH_DASHBOARDS_VERSIONED_DOCS}maptiles`, + // https://opensearch.org/docs/latest/dashboards/gantt/ + ganttCharts: `${OPENSEARCH_DASHBOARDS_VERSIONED_DOCS}gantt`, + // https://opensearch.org/docs/latest/dashboards/reporting/ + reporting: `${OPENSEARCH_DASHBOARDS_VERSIONED_DOCS}reporting`, + // https://opensearch.org/docs/latest/dashboards/notebooks/ + notebooks: `${OPENSEARCH_DASHBOARDS_VERSIONED_DOCS}notebooks`, + // https://opensearch.org/docs/latest/dashboards/dql/ + dql: `${OPENSEARCH_DASHBOARDS_VERSIONED_DOCS}dql`, + }, dashboard: { drilldowns: `${OPENSEARCH_WEBSITE_URL}guide/en/opensearch/${DOC_LINK_VERSION}/drilldowns.html`, drilldownsTriggerPicker: `${OPENSEARCH_WEBSITE_URL}guide/en/opensearch/${DOC_LINK_VERSION}/drilldowns.html#url-drilldowns`, @@ -131,7 +205,6 @@ export class DocLinksService { // TODO: [RENAMEME] Need prod urls. // issue: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/335#issuecomment-868294864 addData: `${OPENSEARCH_DASHBOARDS_DOCS}`, - opensearchDashboards: `${OPENSEARCH_DASHBOARDS_DOCS}`, siem: { guide: `${OPENSEARCH_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/index.html`, gettingStarted: `${OPENSEARCH_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/index.html`, @@ -164,6 +237,44 @@ export interface DocLinksStart { readonly DOC_LINK_VERSION: string; readonly OPENSEARCH_WEBSITE_URL: string; readonly links: { + readonly opensearch: { + readonly introduction: string; + readonly installation: string; + readonly configuration: string; + readonly cluster: string; + readonly indexData: string; + readonly indexAlias: string; + readonly dataStreams: string; + readonly aggregations: { + readonly matric: string; + readonly bucket: string; + readonly pipeline: string; + }; + readonly indexTemplates: string; + readonly reindexData: string; + readonly queryDSL: { + readonly introduction: string; + readonly term: string; + readonly fullText: string; + readonly boolQuery: string; + }; + readonly searchTemplate: string; + readonly searchExperience: string; + readonly logs: string; + readonly snapshotRestore: string; + readonly supportedUnits: string; + readonly commonParameters: string; + readonly popularAPI: string; + }; + readonly opensearchDashboards: { + readonly introduction: string; + readonly installation: string; + readonly mapTiles: string; + readonly ganttCharts: string; + readonly reporting: string; + readonly notebooks: string; + readonly dql: string; + }; readonly dashboard: { readonly drilldowns: string; readonly drilldownsTriggerPicker: string; @@ -241,7 +352,6 @@ export interface DocLinksStart { readonly introduction: string; }; readonly addData: string; - readonly opensearchDashboards: string; readonly siem: { readonly guide: string; readonly gettingStarted: string; diff --git a/src/plugins/console/server/lib/spec_definitions/json/generated/msearch.json b/src/plugins/console/server/lib/spec_definitions/json/generated/msearch.json index 9bd852feb690..ee211859a788 100644 --- a/src/plugins/console/server/lib/spec_definitions/json/generated/msearch.json +++ b/src/plugins/console/server/lib/spec_definitions/json/generated/msearch.json @@ -23,6 +23,6 @@ "{indices}/_msearch", "{indices}/{type}/_msearch" ], - "documentation": "https://opensearch.org/docs/opensearch/query-dsl/full-text/#multi-match" + "documentation": "https://opensearch.org/docs/latest/opensearch/query-dsl/full-text/#multi-match" } } diff --git a/src/plugins/console/server/lib/spec_definitions/json/generated/msearch_template.json b/src/plugins/console/server/lib/spec_definitions/json/generated/msearch_template.json index c8ba83961afe..4c6bfd73be73 100644 --- a/src/plugins/console/server/lib/spec_definitions/json/generated/msearch_template.json +++ b/src/plugins/console/server/lib/spec_definitions/json/generated/msearch_template.json @@ -21,6 +21,6 @@ "{indices}/_msearch/template", "{indices}/{type}/_msearch/template" ], - "documentation": "https://opensearch.org/docs/opensearch/query-dsl/full-text/#multi-match" + "documentation": "https://opensearch.org/docs/latest/opensearch/query-dsl/full-text/#multi-match" } } diff --git a/src/plugins/dashboard/public/application/help_menu/help_menu_util.ts b/src/plugins/dashboard/public/application/help_menu/help_menu_util.ts index ccc2b56a528d..3465d1cb12fc 100644 --- a/src/plugins/dashboard/public/application/help_menu/help_menu_util.ts +++ b/src/plugins/dashboard/public/application/help_menu/help_menu_util.ts @@ -44,9 +44,7 @@ export function addHelpMenuToAppChrome( links: [ { linkType: 'documentation', - // TODO: [RENAMEME] Need prod urls. - // issue: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/335#issuecomment-868294864 - href: `${docLinks.links.opensearchDashboards}`, + href: `${docLinks.links.opensearchDashboards.introduction}`, }, ], }); diff --git a/src/plugins/data/common/opensearch_query/kuery/node_types/wildcard.ts b/src/plugins/data/common/opensearch_query/kuery/node_types/wildcard.ts index bcde8bacc6e7..ee4b3f8ac9fd 100644 --- a/src/plugins/data/common/opensearch_query/kuery/node_types/wildcard.ts +++ b/src/plugins/data/common/opensearch_query/kuery/node_types/wildcard.ts @@ -41,7 +41,7 @@ function escapeRegExp(str: string) { return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } -// See https://www.opensearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters +// See https://opensearch.org/docs/latest/opensearch/query-dsl/index/ function escapeQueryString(str: string) { return str.replace(/[+-=&|> diff --git a/src/plugins/data/public/ui/query_string_input/query_bar_top_row.tsx b/src/plugins/data/public/ui/query_string_input/query_bar_top_row.tsx index f2e02cefe243..df36dc89db93 100644 --- a/src/plugins/data/public/ui/query_string_input/query_bar_top_row.tsx +++ b/src/plugins/data/public/ui/query_string_input/query_bar_top_row.tsx @@ -96,7 +96,7 @@ export default function QueryBarTopRow(props: QueryBarTopRowProps) { const opensearchDashboards = useOpenSearchDashboards(); const { uiSettings, notifications, storage, appName, docLinks } = opensearchDashboards.services; - const kueryQuerySyntaxLink: string = docLinks!.links.query.kueryQuerySyntax; + const kueryQuerySyntaxLink: string = docLinks!.links.opensearchDashboards.dql; const queryLanguage = props.query && props.query.language; const persistedLog: PersistedLog | undefined = React.useMemo( diff --git a/src/plugins/data/public/ui/query_string_input/query_string_input.tsx b/src/plugins/data/public/ui/query_string_input/query_string_input.tsx index 383a4f2db230..685eb551ebc1 100644 --- a/src/plugins/data/public/ui/query_string_input/query_string_input.tsx +++ b/src/plugins/data/public/ui/query_string_input/query_string_input.tsx @@ -409,7 +409,7 @@ export default class QueryStringInputUI extends Component { Learn more in our {link}." values={{ link: ( - + Boolean(f && f.name); - - // https://www.opensearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#_standard_operators + + // See https://opensearch.org/docs/latest/opensearch/query-dsl/index/ const getEscapedQuery = (q: string = '') => q.replace(/[.?+*|{}[\]()"\\#@&<>~]/g, (match) => `\\${match}`); diff --git a/src/plugins/discover/public/application/components/doc/use_opensearch_doc_search.ts b/src/plugins/discover/public/application/components/doc/use_opensearch_doc_search.ts index 0e120a4d565d..b2824b7198dd 100644 --- a/src/plugins/discover/public/application/components/doc/use_opensearch_doc_search.ts +++ b/src/plugins/discover/public/application/components/doc/use_opensearch_doc_search.ts @@ -44,7 +44,7 @@ export enum OpenSearchRequestState { /** * helper function to build a query body for OpenSearch - * https://www.opensearch.org/guide/en/elasticsearch/reference/current//query-dsl-ids-query.html + * https://opensearch.org/docs/latest/opensearch/query-dsl/index/ */ export function buildSearchBody(id: string, indexPattern: IndexPattern): Record { const computedFields = indexPattern.getComputedFields(); diff --git a/src/plugins/discover/public/application/components/help_menu/help_menu_util.js b/src/plugins/discover/public/application/components/help_menu/help_menu_util.js index 11ed192cbcdc..7a0cede7f9bd 100644 --- a/src/plugins/discover/public/application/components/help_menu/help_menu_util.js +++ b/src/plugins/discover/public/application/components/help_menu/help_menu_util.js @@ -42,9 +42,7 @@ export function addHelpMenuToAppChrome(chrome) { links: [ { linkType: 'documentation', - // TODO: [RENAMEME] Need prod urls. - // issue: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/335#issuecomment-868294864 - href: `${docLinks.links.opensearchDashboards}`, + href: `${docLinks.links.opensearchDashboards.introduction}`, }, ], }); diff --git a/src/plugins/input_control_vis/public/control/list_control_factory.ts b/src/plugins/input_control_vis/public/control/list_control_factory.ts index 3d33826be25b..4a5fc2bc2f16 100644 --- a/src/plugins/input_control_vis/public/control/list_control_factory.ts +++ b/src/plugins/input_control_vis/public/control/list_control_factory.ts @@ -45,7 +45,7 @@ import { ControlParams } from '../editor_utils'; import { InputControlSettings, InputControlVisDependencies } from '../plugin'; function getEscapedQuery(query = '') { - // https://www.opensearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#_standard_operators + // https://opensearch.org/docs/latest/opensearch/query-dsl/index/ return query.replace(/[.?+*|{}[\]()"\\#@&<>~]/g, (match) => `\\${match}`); }