-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Enterprise Search] Do not include precision in the search request when precision tuning is not enabled for an Engine #136670
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -365,9 +365,11 @@ describe('RelevanceTuningLogic', () => { | |
| weight: 1, | ||
| }, | ||
| }, | ||
| precision: 7, | ||
| precision_enabled: true, | ||
| }; | ||
|
|
||
| const searchSettingsWithoutNewBoostProp = { | ||
| const { ['precision_enabled']: precisionEnabled, ...searchSettingsWithoutNewBoostProp } = { | ||
| ...searchSettingsWithNewBoostProp, | ||
| boosts: { | ||
| foo: [ | ||
|
|
@@ -378,6 +380,7 @@ describe('RelevanceTuningLogic', () => { | |
| }, | ||
| ], | ||
| }, | ||
| precision: 7, | ||
| }; | ||
|
|
||
| mount({ | ||
|
|
@@ -413,6 +416,38 @@ describe('RelevanceTuningLogic', () => { | |
| searchSettings: { | ||
| searchField: {}, | ||
| boosts: {}, | ||
| precision: 7, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check |
||
| precision_enabled: true, | ||
| }, | ||
| }); | ||
| jest.spyOn(RelevanceTuningLogic.actions, 'setSearchResults'); | ||
| http.post.mockReturnValueOnce( | ||
| Promise.resolve({ | ||
| results: searchResults, | ||
| }) | ||
| ); | ||
|
|
||
| RelevanceTuningLogic.actions.getSearchResults(); | ||
|
|
||
| jest.runAllTimers(); | ||
| await nextTick(); | ||
|
|
||
| expect(http.post).toHaveBeenCalledWith('/internal/app_search/engines/test-engine/search', { | ||
| body: JSON.stringify({ precision: 7 }), | ||
| query: { | ||
| query: 'foo', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it("won't send precision on the API call if it is not enabled", async () => { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add test for |
||
| mount({ | ||
| query: 'foo', | ||
| searchSettings: { | ||
| searchField: {}, | ||
| boosts: {}, | ||
| precision: 7, | ||
| precision_enabled: false, | ||
| }, | ||
| }); | ||
| jest.spyOn(RelevanceTuningLogic.actions, 'setSearchResults'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,6 +294,7 @@ export const RelevanceTuningLogic = kea< | |
| actions.setResultsLoading(true); | ||
|
|
||
| const filteredBoosts = removeEmptyValueBoosts(boosts); | ||
| const precisionSettings = values.isPrecisionTuningEnabled ? { precision } : {}; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actual fix (thanks @afoucret !): Do not send precision when precision tuning is not enabled |
||
|
|
||
| try { | ||
| const response = await http.post<{ results: SearchResult[] }>(url, { | ||
|
|
@@ -303,7 +304,7 @@ export const RelevanceTuningLogic = kea< | |
| body: JSON.stringify({ | ||
| boosts: isEmpty(filteredBoosts) ? undefined : filteredBoosts, | ||
| search_fields: isEmpty(searchFields) ? undefined : searchFields, | ||
| precision, | ||
| ...precisionSettings, | ||
| }), | ||
| }); | ||
|
|
||
|
|
||
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.
Check
precisionis being sent, butprecision_enabledis not