[Ent Search Deprecation] Redirect enterprise_search to elasticsearch Urls (#204890)

This PR resolves this
https://github.com/elastic/search-team/issues/7961. This PR redirects
all enterprise_search urls to elasticsearch urls.



https://github.com/user-attachments/assets/d0fec395-f758-478f-a478-ad12ccdd57dd

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Saikat Sarkar 2025-01-02 11:41:09 -07:00 committed by GitHub
parent 6a84cccbde
commit ca28d2dc5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 263 additions and 0 deletions

View file

@ -141,6 +141,7 @@ export const applicationUsageSchema = {
enterpriseSearchAnalytics: commonSchema,
enterpriseSearchApplications: commonSchema,
enterpriseSearchAISearch: commonSchema,
enterpriseSearchRedirect: commonSchema,
enterpriseSearchSemanticSearch: commonSchema,
enterpriseSearchVectorSearch: commonSchema,
enterpriseSearchElasticsearch: commonSchema,

View file

@ -2753,6 +2753,137 @@
}
}
},
"enterpriseSearchRedirect": {
"properties": {
"appId": {
"type": "keyword",
"_meta": {
"description": "The application being tracked"
}
},
"viewId": {
"type": "keyword",
"_meta": {
"description": "Always `main`"
}
},
"clicks_total": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application since we started counting them"
}
},
"clicks_7_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application over the last 7 days"
}
},
"clicks_30_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application over the last 30 days"
}
},
"clicks_90_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application over the last 90 days"
}
},
"minutes_on_screen_total": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen since we started counting them."
}
},
"minutes_on_screen_7_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen over the last 7 days"
}
},
"minutes_on_screen_30_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen over the last 30 days"
}
},
"minutes_on_screen_90_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen over the last 90 days"
}
},
"views": {
"type": "array",
"items": {
"properties": {
"appId": {
"type": "keyword",
"_meta": {
"description": "The application being tracked"
}
},
"viewId": {
"type": "keyword",
"_meta": {
"description": "The application view being tracked"
}
},
"clicks_total": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application sub view since we started counting them"
}
},
"clicks_7_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the active application sub view over the last 7 days"
}
},
"clicks_30_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the active application sub view over the last 30 days"
}
},
"clicks_90_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the active application sub view over the last 90 days"
}
},
"minutes_on_screen_total": {
"type": "float",
"_meta": {
"description": "Minutes the application sub view is active and on-screen since we started counting them."
}
},
"minutes_on_screen_7_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen active application sub view over the last 7 days"
}
},
"minutes_on_screen_30_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen active application sub view over the last 30 days"
}
},
"minutes_on_screen_90_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen active application sub view over the last 90 days"
}
}
}
}
}
}
},
"enterpriseSearchSemanticSearch": {
"properties": {
"appId": {

View file

@ -0,0 +1,51 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { render, waitFor } from '@testing-library/react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { ApplicationRedirect } from '.';
jest.mock('@kbn/kibana-react-plugin/public', () => ({
useKibana: jest.fn(),
}));
describe('RedirectWithReplace', () => {
const navigateToUrlMock = jest.fn();
const coreMock = {
application: {
navigateToUrl: navigateToUrlMock,
},
};
beforeEach(() => {
(useKibana as jest.Mock).mockReturnValue({ services: coreMock });
// Mock window.location.pathname
Object.defineProperty(window, 'location', {
writable: true,
value: { pathname: '/enterprise_search/content/search_indices' },
});
});
it('should redirect to the new path', async () => {
render(
<MemoryRouter>
<ApplicationRedirect />
</MemoryRouter>
);
await waitFor(() => {
expect(navigateToUrlMock).toHaveBeenCalledWith('/elasticsearch/content/search_indices');
});
});
});

View file

@ -0,0 +1,35 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React, { useEffect } from 'react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { Routes, Route } from '@kbn/shared-ux-router';
const RedirectWithReplace = () => {
const { application } = useKibana().services;
useEffect(() => {
const fullPath = location.pathname;
// Construct the new path by replacing 'enterprise_search' with 'elasticsearch'
const newPath = fullPath.replace('/enterprise_search', '/elasticsearch');
// Perform the client-side navigation using core
application?.navigateToUrl(newPath);
}, []);
return null;
};
export const ApplicationRedirect = () => {
return (
<Routes>
<Route path="/*" component={RedirectWithReplace} />
</Routes>
);
};

View file

@ -0,0 +1,28 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../../../../../..',
roots: [
'<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/enterprise_search_redirect',
],
collectCoverage: true,
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/**/*.{ts,tsx}',
'!<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/*.ts',
'!<rootDir>/x-pack/solutions/search/plugins/enterprise_search/server/*.ts',
'!<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/test_helpers/**/*.{ts,tsx}',
],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/x-pack/solutions/search/plugins/enterprise_search/public/applications/enterprise_search_redirect',
modulePathIgnorePatterns: [
'<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/app_search/cypress',
'<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/workplace_search/cypress',
],
};

View file

@ -489,6 +489,23 @@ export class EnterpriseSearchPlugin implements Plugin {
visibleIn: [],
});
core.application.register({
appRoute: '/app/enterprise_search',
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
id: 'enterpriseSearchRedirect',
mount: async (params: AppMountParameters) => {
const kibanaDeps = await this.getKibanaDeps(core, params, cloud);
const pluginData = this.getPluginData();
const { renderApp } = await import('./applications');
const { ApplicationRedirect } = await import('./applications/enterprise_search_redirect');
return renderApp(ApplicationRedirect, kibanaDeps, pluginData);
},
title: 'EnterpriseSearchRedirect',
visibleIn: [],
});
if (plugins.home) {
plugins.home.featureCatalogue.registerSolution({
description: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.DESCRIPTION,