-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
@@ -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`; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+10000000000000000
There was a problem hiding this comment.
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.
export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/relevance-tuning`; | |
export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/relevance_tuning`; |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
vsquery
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
aec3666
to
643c874
Compare
x-pack/plugins/enterprise_search/server/__mocks__/router.mock.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+10000000000000000
x-pack/plugins/enterprise_search/server/__mocks__/router.mock.ts
Outdated
Show resolved
Hide resolved
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
mockRouter = new MockRouter({ | ||
method: 'get', | ||
path: '/api/app_search/engines/{engineName}/search_settings/details', | ||
}); | ||
|
||
registerSearchSettingsRoutes({ | ||
...mockDependencies, | ||
router: mockRouter.router, | ||
}); | ||
}); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; |
There was a problem hiding this comment.
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
x-pack/plugins/enterprise_search/server/routes/app_search/search_settings.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/enterprise_search/server/routes/app_search/search_settings.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/enterprise_search/server/routes/app_search/search_settings.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/enterprise_search/server/routes/app_search/search_settings.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/enterprise_search/server/routes/app_search/search_settings.ts
Outdated
Show resolved
Hide resolved
Taking a break for a late breakfast, will come back here in a bit to look at the rest of the PR |
...plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/enterprise_search/server/routes/app_search/search_settings.test.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/enterprise_search/server/__mocks__/router.mock.ts
Outdated
Show resolved
Hide resolved
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made changes
@elasticmachine merge upstream |
There was a problem hiding this 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
x-pack/plugins/enterprise_search/server/__mocks__/router.mock.ts
Outdated
Show resolved
Hide resolved
const queryRouter = new MockRouter({ | ||
method: 'post', | ||
path: '/api/app_search/engines/{engineName}/search_settings_search', | ||
payload: 'query', | ||
}); |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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!
@elasticmachine merge upstream |
There was a problem hiding this 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
kibanamachine pls 😩 |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
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