[Search] Fix unrecognized parameter: [indexType] error (#212707)

## Summary

This PR fixes an issue introduced in #208776 where switching from ES|QL
mode to classic mode in Discover caused the search request to fail with
an `unrecognized parameter: [indexType]` error. This was because the
`indexType` was actually being sent as part of the search request
`params` when it shouldn't have been.

We already had some rollup tests that would have caught it, but a
workaround was also added to the rollup search strategy to sidestep the
issue, preventing the tests from failing. That workaround has been
removed and existing ES|QL tests updated to catch the issue specifically
for ES|QL mode.

Fixes #212704.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
Davis McPhee 2025-03-04 20:33:41 -04:00 committed by GitHub
parent 3ce9019ce3
commit 80c142a5db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 7 deletions

View file

@ -544,12 +544,12 @@ export class SearchSource {
options: SearchSourceSearchOptions
): Observable<IKibanaSearchResponse<unknown>> {
const { search, getConfig, onResponse } = this.dependencies;
const params = getSearchParamsFromRequest(searchRequest, {
const { indexType, ...restRequest } = searchRequest;
const params = getSearchParamsFromRequest(restRequest, {
getConfig,
});
return search({ params, indexType: searchRequest.indexType }, options).pipe(
return search({ params, indexType }, options).pipe(
switchMap((response) => {
// For testing timeout messages in UI, uncomment the next line
// response.rawResponse.timed_out = true;

View file

@ -13,7 +13,6 @@ import { catchError, tap } from 'rxjs';
import { firstValueFrom, from } from 'rxjs';
import type { ISearchOptions, IEsSearchRequest, IEsSearchResponse } from '@kbn/search-types';
import { getKbnServerError } from '@kbn/kibana-utils-plugin/server';
import { omit } from 'lodash';
import { IAsyncSearchRequestParams } from '../..';
import { getKbnSearchError, KbnSearchError } from '../../report_search_error';
import type { ISearchStrategy, SearchStrategyDependencies } from '../../types';
@ -171,7 +170,7 @@ export const enhancedEsSearchStrategyProvider = (
const esResponse = await client.rollup.rollupSearch(
{
...querystring,
...omit(request.params, ['indexType']),
...request.params,
index: request.params.index,
},
{

View file

@ -318,7 +318,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});
it('should show available data views after switching to classic mode', async () => {
it('should show available data views and search results after switching to classic mode', async () => {
await discover.selectTextBaseLang();
await header.waitUntilLoadingHasFinished();
await discover.waitUntilSearchingHasFinished();
@ -329,6 +329,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await unifiedSearch.switchToDataViewMode();
await header.waitUntilLoadingHasFinished();
await discover.waitUntilSearchingHasFinished();
await discover.assertHitCount('14,004');
const availableDataViews = await unifiedSearch.getDataViewList(
'discover-dataView-switch-link'
);

View file

@ -318,7 +318,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});
it('should show available data views after switching to classic mode', async () => {
it('should show available data views and search results after switching to classic mode', async () => {
await PageObjects.discover.selectTextBaseLang();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.discover.waitUntilSearchingHasFinished();
@ -329,6 +329,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.unifiedSearch.switchToDataViewMode();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.assertHitCount('14,004');
const availableDataViews = await PageObjects.unifiedSearch.getDataViewList(
'discover-dataView-switch-link'
);