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

[App Search] Relevance Tuning stub page and server routes #89308

Merged
merged 14 commits into from
Feb 3, 2021

Conversation

JasonStoltz
Copy link
Member

@JasonStoltz JasonStoltz commented Jan 26, 2021

Summary

This is Part 1 of Relevance Tuning.

It includes a stub page for Relevance Tuning, as well as the corresponding API server routes.

Checklist

@@ -41,7 +41,7 @@ export const ENGINE_CRAWLER_PATH = `${ENGINE_PATH}/crawler`;

export const META_ENGINE_SOURCE_ENGINES_PATH = `${ENGINE_PATH}/engines`;

export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/search-settings`;
export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/relevance-tuning`;
Copy link
Member Author

@JasonStoltz JasonStoltz Jan 26, 2021

Choose a reason for hiding this comment

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

For the view and all view components, I am using Relevance Tuning over search settings, to match how we actually present it to a user.

Copy link
Contributor

Choose a reason for hiding this comment

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

+10000000000000000

Copy link
Contributor

@cee-chen cee-chen Jan 29, 2021

Choose a reason for hiding this comment

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

Quick heads up (I'll continue reminding folks as we port over pages, no worries), URLs should be snake_cased in Kibana, not kebab-cased - I have non-migrated URLs currently in kebab-case so that they still work when generating URLs to App Search.

Suggested change
export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/relevance-tuning`;
export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/relevance_tuning`;

Copy link
Member Author

Choose a reason for hiding this comment

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

* you may not use this file except in compliance with the Elastic License.
*/

import { schema } from '@kbn/config-schema';
Copy link
Member Author

Choose a reason for hiding this comment

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

I am treating these routes as pass through. For that reason, you will see the following 3 things:

  • These are still named Search Settings, NOT Relevance Tuning. This is to stay 1 to 1 with the backend search settings API.
  • Original routes have not been modified
  • I am doing no more than a high level check for keys as validation. I do not want to introduce redundant schema validation, since this is already validated on the server.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am doing no more than a high level check for keys as validation. I do not want to introduce redundant schema validation, since this is already validated on the server.

I think this is fine, but I think we should come to a consensus on how we want to handle this sort of validation universally

Copy link
Contributor

@cee-chen cee-chen Jan 29, 2021

Choose a reason for hiding this comment

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

I'm fine with this as part of migration speed, but I'd really like to come back and do a cleanup round this post-MVP. There are a lot of issues with our current backend APIs:

  • Not RESTful, inconsistent naming (e.g. queries vs query in the Analytics APIs, and I still don't know what the logic was behind /detail and /collection routes)
  • Inconsistent casing all over the place with both sent and returned payloads, etc.
  • Old/outdated naming (Search Settings vs Relevance Tuning, Reference UI vs Search UI, etc. etc.)

That being said hopefully one of our future goals is to move to our public APIs anyway and not rely so much on internal ones, so who knows what the future holds.

Re: validation, ya I think we'd need to deeper dive into that as well whenever we circle back. One thing to potentially think about is that schema errors we catch in Kibana can potentially be i18n'd, whereas errors we get back from the server are always in English. I actually don't know if there's a good solution to that and we may just have to be OK with it, but it's definitely an interesting topic at least

@JasonStoltz JasonStoltz added release_note:skip Skip the PR/issue when compiling release notes v7.12.0 Feature:Plugins labels Jan 26, 2021
@JasonStoltz JasonStoltz marked this pull request as ready for review January 26, 2021 15:24
@JasonStoltz JasonStoltz requested review from a team January 26, 2021 15:24
Copy link
Contributor

@byronhulcher byronhulcher left a comment

Choose a reason for hiding this comment

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

Two small change requests, I think the typescript comment is especially worth adding.

@@ -41,7 +41,7 @@ export const ENGINE_CRAWLER_PATH = `${ENGINE_PATH}/crawler`;

export const META_ENGINE_SOURCE_ENGINES_PATH = `${ENGINE_PATH}/engines`;

export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/search-settings`;
export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/relevance-tuning`;
Copy link
Contributor

Choose a reason for hiding this comment

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

+10000000000000000

Comment on lines 28 to 39
beforeEach(() => {
jest.clearAllMocks();
mockRouter = new MockRouter({
method: 'get',
path: '/api/app_search/engines/{engineName}/search_settings/details',
});

registerSearchSettingsRoutes({
...mockDependencies,
router: mockRouter.router,
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Naive question, but why is this in a beforeEach rather than a beforeAll? Couldn't the mock persist since it's not being changed in between it tests?

Copy link
Member Author

@JasonStoltz JasonStoltz Jan 29, 2021

Choose a reason for hiding this comment

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

I was definitely doing more than I needed to do here. jest.clearAllMocks was redundant as I was already doing that in a beforeAll at the root.

Instantiating mockRouter only ever needs to be done once, EXCEPT in the query tests, which I had to create a new router for because it tests query validation not body, and you can only test validate on one or the other with a mock router.

registerSearchSettingsRoutes must be done in a beforeEach, because it registers a call to a mock that is required for route specs, and since mocks get cleared before every test, it will fail every test.

dcc92e3

* you may not use this file except in compliance with the Elastic License.
*/

import { schema } from '@kbn/config-schema';
Copy link
Contributor

Choose a reason for hiding this comment

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

I am doing no more than a high level check for keys as validation. I do not want to introduce redundant schema validation, since this is already validated on the server.

I think this is fine, but I think we should come to a consensus on how we want to handle this sort of validation universally

@cee-chen
Copy link
Contributor

Taking a break for a late breakfast, will come back here in a bit to look at the rest of the PR

@cee-chen
Copy link
Contributor

Those are my last set of comments, thanks so much for your patience Jason! All my change requests are in ```suggestion blocks, everything else is optional.

Copy link
Member Author

@JasonStoltz JasonStoltz left a comment

Choose a reason for hiding this comment

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

Made changes

@cee-chen
Copy link
Contributor

cee-chen commented Feb 1, 2021

@elasticmachine merge upstream

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Awesome stuff, thanks Jason! Not sure why CI is failing, I kicked off a new build and will try to keep an eye on that here

Comment on lines +190 to +194
const queryRouter = new MockRouter({
method: 'post',
path: '/api/app_search/engines/{engineName}/search_settings_search',
payload: 'query',
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I think I need to rethink how I handle payload validation if we're having to create a brand new router for validating body vs query etc. It hadn't occurred to past-me that we'd have multiple types of payloads to validate. 🤦‍♀️

Basically what I'm thinking of changing API-wise is removing the payload from MockRouter instantiation and only passing it in the actual shouldValidate/shouldThrow fn. That way we'll only need to create a single mock router per route.

I'll follow up with this PR with that refactor if that sounds good to you!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think that sounds great Constance, ty!

@cee-chen
Copy link
Contributor

cee-chen commented Feb 1, 2021

@elasticmachine merge upstream

Copy link
Contributor

@byronhulcher byronhulcher left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in approval, thanks for waiting @JasonStoltz

@cee-chen
Copy link
Contributor

cee-chen commented Feb 2, 2021

kibanamachine pls 😩

@cee-chen
Copy link
Contributor

cee-chen commented Feb 2, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
enterpriseSearch 1187 1188 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
enterpriseSearch 1.8MB 1.8MB +1.3KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants