[ES|QL] Remove version from _query requests (#184053)

## Summary

Removes the versioning from the _query api requests.

This ES PR removes the version from the _query requests
https://github.com/elastic/elasticsearch/pull/108919 and got backported
at 8.14 too. We need to also remove it from our side too to be in sync
with ES changes.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Stratoula Kalafateli 2024-05-24 15:44:52 +02:00 committed by GitHub
parent 5de72f5f2d
commit 5c78c01321
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 12 additions and 72 deletions

View file

@ -688,7 +688,6 @@ export interface ESQLSearchParams {
// https://github.com/elastic/elasticsearch/pull/102767
// time_zone?: string;
query: string;
version: string;
filter?: unknown;
locale?: string;
dropNullColumns?: boolean;

View file

@ -5,8 +5,6 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
// we are expecting to retrieve this from an API instead
// https://github.com/elastic/elasticsearch/issues/107069
// only used for security solution
export const ESQL_LATEST_VERSION = '2024.04.01';
export const ENABLE_ESQL = 'enableESQL';

View file

@ -22,4 +22,4 @@ export {
TextBasedLanguages,
} from './src';
export { ESQL_LATEST_VERSION, ENABLE_ESQL } from './constants';
export { ENABLE_ESQL, ESQL_LATEST_VERSION } from './constants';

View file

@ -11,7 +11,6 @@ import type { ISearchGeneric } from '@kbn/search-types';
import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
import type { ESQLColumn, ESQLSearchReponse, ESQLSearchParams } from '@kbn/es-types';
import { lastValueFrom } from 'rxjs';
import { ESQL_LATEST_VERSION } from '../../constants';
export function formatESQLColumns(columns: ESQLColumn[]): DatatableColumn[] {
return columns.map(({ name, type }) => {
@ -41,7 +40,6 @@ export async function getESQLQueryColumnsRaw({
{
params: {
query: `${esqlQuery} | limit 0`,
version: ESQL_LATEST_VERSION,
},
},
{
@ -76,7 +74,6 @@ export async function getESQLQueryColumns({
try {
const rawColumns = await getESQLQueryColumnsRaw({ esqlQuery, search, signal });
const columns = formatESQLColumns(rawColumns) ?? [];
return columns;
} catch (error) {
throw new Error(
@ -112,7 +109,6 @@ export async function getESQLResults({
params: {
...(filter ? { filter } : {}),
query: esqlQuery,
version: ESQL_LATEST_VERSION,
...(dropNullColumns ? { dropNullColumns: true } : {}),
},
},

View file

@ -22,7 +22,6 @@ import type { IKibanaSearchResponse } from '@kbn/search-types';
import { IScopedSearchClient } from '@kbn/data-plugin/server';
import { dataPluginMock } from '@kbn/data-plugin/server/mocks';
import { CancellationToken } from '@kbn/reporting-common';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import type { ReportingConfigType } from '@kbn/reporting-server';
import type { ESQLSearchReponse as ESQLSearchResponse } from '@kbn/es-types';
import {
@ -312,7 +311,7 @@ describe('CsvESQLGenerator', () => {
);
expect(mockDataClientSearchFn).toBeCalledWith(
{ params: { filter: undefined, locale: 'en', query: '', version: ESQL_LATEST_VERSION } },
{ params: { filter: undefined, locale: 'en', query: '' } },
{
strategy: 'esql',
transport: {
@ -390,7 +389,7 @@ describe('CsvESQLGenerator', () => {
);
expect(mockDataClientSearchFn).toBeCalledWith(
{ params: { filter: undefined, locale: 'en', query: '', version: ESQL_LATEST_VERSION } },
{ params: { filter: undefined, locale: 'en', query: '' } },
{
strategy: 'esql',
transport: {
@ -486,7 +485,6 @@ describe('CsvESQLGenerator', () => {
},
locale: 'en',
query: '',
version: ESQL_LATEST_VERSION,
},
},
{

View file

@ -8,7 +8,6 @@
import { lastValueFrom } from 'rxjs';
import type { Writable } from 'stream';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { errors as esErrors } from '@elastic/elasticsearch';
import type { IScopedClusterClient, IUiSettingsClient, Logger } from '@kbn/core/server';
import type { IKibanaSearchResponse, IKibanaSearchRequest } from '@kbn/search-types';
@ -95,7 +94,6 @@ export class CsvESQLGenerator {
// we will need to add it back in once it is supported again.
// https://github.com/elastic/elasticsearch/pull/102767
// timezone
version: ESQL_LATEST_VERSION,
},
};

View file

@ -28,7 +28,6 @@
"@kbn/reporting-export-types-csv-common",
"@kbn/es-query",
"@kbn/es-types",
"@kbn/esql-utils",
"@kbn/data-views-plugin",
"@kbn/search-types",
]

View file

@ -19,7 +19,6 @@ import { catchError, map, switchMap, tap } from 'rxjs';
import { buildEsQuery } from '@kbn/es-query';
import type { ISearchGeneric } from '@kbn/search-types';
import type { ESQLSearchReponse, ESQLSearchParams } from '@kbn/es-types';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { getEsQueryConfig } from '../../es_query';
import { getTime } from '../../query';
import { ESQL_ASYNC_SEARCH_STRATEGY, KibanaContext } from '..';
@ -148,7 +147,6 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
query,
// time_zone: timezone,
locale,
version: ESQL_LATEST_VERSION,
};
if (input) {
const esQueryConfigs = getEsQueryConfig(

View file

@ -8,7 +8,6 @@
import { firstValueFrom } from 'rxjs';
import { KbnServerError } from '@kbn/kibana-utils-plugin/server';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { KbnSearchError } from '../../report_search_error';
import { errors } from '@elastic/elasticsearch';
import indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
@ -67,7 +66,6 @@ describe('ES|QL async search strategy', () => {
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
await esSearch
.search(
@ -91,7 +89,6 @@ describe('ES|QL async search strategy', () => {
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
@ -111,7 +108,6 @@ describe('ES|QL async search strategy', () => {
query: 'from logs* | limit 10',
wait_for_completion_timeout: '10s',
keep_alive: '5m',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
@ -127,7 +123,7 @@ describe('ES|QL async search strategy', () => {
it('sets transport options on POST requests', async () => {
const transportOptions = { maxRetries: 1 };
mockApiCaller.mockResolvedValueOnce(mockAsyncResponse);
const params = { query: 'from logs', version: ESQL_LATEST_VERSION };
const params = { query: 'from logs' };
const esSearch = esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
await firstValueFrom(
@ -144,7 +140,6 @@ describe('ES|QL async search strategy', () => {
wait_for_completion_timeout: '100ms',
keep_on_completion: false,
query: 'from logs',
version: ESQL_LATEST_VERSION,
},
}),
expect.objectContaining({ maxRetries: 1, meta: true, signal: undefined })
@ -155,7 +150,6 @@ describe('ES|QL async search strategy', () => {
mockApiCaller.mockResolvedValueOnce(mockAsyncResponse);
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
@ -181,7 +175,6 @@ describe('ES|QL async search strategy', () => {
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
@ -204,7 +197,6 @@ describe('ES|QL async search strategy', () => {
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
const abortController = new AbortController();
@ -238,7 +230,6 @@ describe('ES|QL async search strategy', () => {
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);
@ -262,7 +253,6 @@ describe('ES|QL async search strategy', () => {
const params = {
query: 'from logs* | limit 10',
version: ESQL_LATEST_VERSION,
};
const esSearch = await esqlAsyncSearchStrategyProvider(mockSearchConfig, mockLogger);

View file

@ -54,7 +54,6 @@
"@kbn/es-types",
"@kbn/code-editor",
"@kbn/core-test-helpers-model-versions",
"@kbn/esql-utils",
"@kbn/react-kibana-mount",
"@kbn/search-types"
],

View file

@ -11,7 +11,6 @@ import Path from 'path';
import expect from '@kbn/expect';
import { MappingProperty } from '@elastic/elasticsearch/lib/api/types';
import { REPO_ROOT } from '@kbn/repo-info';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import uniqBy from 'lodash/uniqBy';
import { groupBy, mapValues } from 'lodash';
import { FtrProviderContext } from '../../ftr_provider_context';
@ -127,7 +126,6 @@ export default function ({ getService }: FtrProviderContext) {
path: '/_query',
body: {
query,
version: ESQL_LATEST_VERSION,
},
});
return { resp, error: undefined };

View file

@ -8,7 +8,6 @@
import expect from '@kbn/expect';
import request from 'superagent';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { inflateResponse } from '@kbn/bfetch-plugin/public/streaming';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { BFETCH_ROUTE_VERSION_LATEST } from '@kbn/bfetch-plugin/common';
@ -414,7 +413,6 @@ export default function ({ getService }: FtrProviderContext) {
request: {
params: {
query: 'from .kibana | limit 1',
version: ESQL_LATEST_VERSION,
},
},
options: {
@ -443,7 +441,6 @@ export default function ({ getService }: FtrProviderContext) {
request: {
params: {
query: 'fro .kibana | limit 1',
version: ESQL_LATEST_VERSION,
},
},
options: {

View file

@ -72,7 +72,6 @@
"@kbn/links-plugin",
"@kbn/ftr-common-functional-ui-services",
"@kbn/monaco",
"@kbn/esql-utils",
"@kbn/search-types",
]
}

View file

@ -14,7 +14,7 @@ import { type UseCancellableSearch, useCancellableSearch } from '@kbn/ml-cancell
import type { estypes } from '@elastic/elasticsearch';
import type { ISearchOptions } from '@kbn/search-types';
import type { TimeBucketsInterval } from '@kbn/ml-time-buckets';
import { getESQLWithSafeLimit, ESQL_LATEST_VERSION, appendToESQLQuery } from '@kbn/esql-utils';
import { getESQLWithSafeLimit, appendToESQLQuery } from '@kbn/esql-utils';
import { isDefined } from '@kbn/ml-is-defined';
import { OMIT_FIELDS } from '../../../../../common/constants';
import type {
@ -94,7 +94,6 @@ const getESQLDocumentCountStats = async (
params: {
query: aggQuery,
...(filter ? { filter } : {}),
version: ESQL_LATEST_VERSION,
},
};
try {
@ -140,7 +139,6 @@ const getESQLDocumentCountStats = async (
params: {
query: appendToESQLQuery(esqlBaseQuery, ' | STATS _count_ = COUNT(*) | LIMIT 1'),
...(filter ? { filter } : {}),
version: ESQL_LATEST_VERSION,
},
};
try {
@ -270,7 +268,6 @@ export const useESQLOverallStatsData = (
// Doing this to match with the default limit
query: esqlBaseQuery,
...(filter ? { filter } : {}),
version: ESQL_LATEST_VERSION,
dropNullColumns: true,
},
},

View file

@ -9,7 +9,7 @@ import type { UseCancellableSearch } from '@kbn/ml-cancellable-search';
import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types';
import { ESQL_SEARCH_STRATEGY } from '@kbn/data-plugin/common';
import pLimit from 'p-limit';
import { ESQL_LATEST_VERSION, appendToESQLQuery } from '@kbn/esql-utils';
import { appendToESQLQuery } from '@kbn/esql-utils';
import type { Column } from '../../hooks/esql/use_esql_overall_stats_data';
import { getSafeESQLName } from '../requests/esql_utils';
import { isFulfilled, isRejected } from '../../../common/util/promise_all_settled_utils';
@ -49,7 +49,6 @@ export const getESQLBooleanFieldStats = async ({
params: {
query,
...(filter ? { filter } : {}),
version: ESQL_LATEST_VERSION,
},
},
};

View file

@ -9,7 +9,7 @@ import pLimit from 'p-limit';
import { chunk } from 'lodash';
import { isDefined } from '@kbn/ml-is-defined';
import type { ESQLSearchReponse } from '@kbn/es-types';
import { ESQL_LATEST_VERSION, appendToESQLQuery } from '@kbn/esql-utils';
import { appendToESQLQuery } from '@kbn/esql-utils';
import type { UseCancellableSearch } from '@kbn/ml-cancellable-search';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { i18n } from '@kbn/i18n';
@ -109,7 +109,6 @@ const getESQLOverallStatsInChunk = async ({
params: {
query,
...(filter ? { filter } : {}),
version: ESQL_LATEST_VERSION,
},
};

View file

@ -8,7 +8,7 @@
import type { UseCancellableSearch } from '@kbn/ml-cancellable-search';
import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types';
import { ESQL_SEARCH_STRATEGY } from '@kbn/data-plugin/common';
import { ESQL_LATEST_VERSION, appendToESQLQuery } from '@kbn/esql-utils';
import { appendToESQLQuery } from '@kbn/esql-utils';
import type { Column } from '../../hooks/esql/use_esql_overall_stats_data';
import { getSafeESQLName } from '../requests/esql_utils';
import type { DateFieldStats, FieldStatsError } from '../../../../../common/types/field_stats';
@ -42,7 +42,6 @@ export const getESQLDateFieldStats = async ({
params: {
query,
...(filter ? { filter } : {}),
version: ESQL_LATEST_VERSION,
},
};
try {

View file

@ -9,7 +9,7 @@ import type { UseCancellableSearch } from '@kbn/ml-cancellable-search';
import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types';
import { ESQL_SEARCH_STRATEGY } from '@kbn/data-plugin/common';
import pLimit from 'p-limit';
import { ESQL_LATEST_VERSION, appendToESQLQuery } from '@kbn/esql-utils';
import { appendToESQLQuery } from '@kbn/esql-utils';
import type { Column } from '../../hooks/esql/use_esql_overall_stats_data';
import { getSafeESQLName } from '../requests/esql_utils';
import { isFulfilled, isRejected } from '../../../common/util/promise_all_settled_utils';
@ -47,7 +47,6 @@ export const getESQLKeywordFieldStats = async ({
params: {
query,
...(filter ? { filter } : {}),
version: ESQL_LATEST_VERSION,
},
},
};

View file

@ -8,7 +8,7 @@
import type { UseCancellableSearch } from '@kbn/ml-cancellable-search';
import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types';
import { ESQL_SEARCH_STRATEGY } from '@kbn/data-plugin/common';
import { ESQL_LATEST_VERSION, appendToESQLQuery } from '@kbn/esql-utils';
import { appendToESQLQuery } from '@kbn/esql-utils';
import { chunk } from 'lodash';
import pLimit from 'p-limit';
import type { Column } from '../../hooks/esql/use_esql_overall_stats_data';
@ -71,7 +71,6 @@ const getESQLNumericFieldStatsInChunk = async ({
params: {
query,
...(filter ? { filter } : {}),
version: ESQL_LATEST_VERSION,
},
};
try {

View file

@ -11,11 +11,7 @@ import { lastValueFrom } from 'rxjs';
import { tap } from 'rxjs';
import { v4 as uuidv4 } from 'uuid';
import { Adapters } from '@kbn/inspector-plugin/common/adapters';
import {
getIndexPatternFromESQLQuery,
getLimitFromESQLQuery,
ESQL_LATEST_VERSION,
} from '@kbn/esql-utils';
import { getIndexPatternFromESQLQuery, getLimitFromESQLQuery } from '@kbn/esql-utils';
import { buildEsQuery } from '@kbn/es-query';
import type { Filter, Query } from '@kbn/es-query';
import type { ESQLSearchParams, ESQLSearchReponse } from '@kbn/es-types';
@ -157,7 +153,6 @@ export class ESQLSource
const params: ESQLSearchParams = {
query: this._descriptor.esql,
dropNullColumns: true,
version: ESQL_LATEST_VERSION,
};
const query: Query[] = [];

View file

@ -11,7 +11,6 @@ FROM library
| SORT year
| LIMIT 5
""",
"version": "2024.04.01"
```
}
@ -49,9 +48,6 @@ For syntax, refer to Returning localized results.
Passing parameters to a query.
`query`
(Required, string) ES|QL query to run. For syntax, refer to Syntax reference.
`version`
(Required, string) ES|QL language version. Can be sent in short or long form, e.g.
`2024.04.01` or `2024.04.01.🚀`. See Language versions for details.
Response bodyedit
`columns`
(array of objects)

View file

@ -11,7 +11,6 @@ import pLimit from 'p-limit';
import Path from 'path';
import { lastValueFrom, startWith } from 'rxjs';
import { promisify } from 'util';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { FunctionVisibility, MessageRole } from '@kbn/observability-ai-assistant-plugin/common';
import {
VisualizeESQLUserIntention,
@ -127,7 +126,6 @@ export function registerQueryFunction({ functions, resources }: FunctionRegistra
path: '_query',
body: {
query,
version: ESQL_LATEST_VERSION,
},
})) as ESQLSearchReponse;

View file

@ -8,7 +8,6 @@
import { validateQuery } from '@kbn/esql-validation-autocomplete';
import { getAstAndSyntaxErrors } from '@kbn/esql-ast';
import type { ElasticsearchClient } from '@kbn/core/server';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { ESQLSearchReponse } from '@kbn/es-types';
import { esFieldTypeToKibanaFieldType, type KBN_FIELD_TYPES } from '@kbn/field-types';
import { splitIntoCommands } from './correct_common_esql_mistakes';
@ -57,7 +56,6 @@ export async function validateEsqlQuery({
path: '_query',
body: {
query: performantQuery,
version: ESQL_LATEST_VERSION,
},
})
.then((res) => {

View file

@ -67,7 +67,6 @@ describe('fetchEsqlQuery', () => {
},
},
"query": "from test",
"version": "2024.04.01",
}
`);
});
@ -95,7 +94,6 @@ describe('fetchEsqlQuery', () => {
},
},
"query": "from test | limit 100",
"version": "2024.04.01",
}
`);
});

View file

@ -6,7 +6,6 @@
*/
import { parseAggregationResults } from '@kbn/triggers-actions-ui-plugin/common';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { SharePluginStart } from '@kbn/share-plugin/server';
import { IScopedClusterClient, Logger } from '@kbn/core/server';
import { OnlyEsqlQueryRuleParams } from '../types';
@ -91,7 +90,6 @@ export const getEsqlQuery = (
const query = {
query: alertLimit ? `${params.esqlQuery.esql} | limit ${alertLimit}` : params.esqlQuery.esql,
version: ESQL_LATEST_VERSION,
filter: {
bool: {
filter: rangeFilter,

View file

@ -8,7 +8,6 @@
import request from 'superagent';
import { inflateResponse } from '@kbn/bfetch-plugin/public/streaming';
import expect from '@kbn/expect';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { BFETCH_ROUTE_VERSION_LATEST } from '@kbn/bfetch-plugin/common';
import type { FtrProviderContext } from '../../ftr_provider_context';
@ -38,7 +37,6 @@ export default function ({ getService }: FtrProviderContext) {
request: {
params: {
query: 'from logstash-* | keep geo.coordinates | limit 0',
version: ESQL_LATEST_VERSION,
},
},
options: {
@ -74,7 +72,6 @@ export default function ({ getService }: FtrProviderContext) {
dropNullColumns: true,
query:
'from logstash-* | keep geo.coordinates, @timestamp | sort @timestamp | limit 1',
version: ESQL_LATEST_VERSION,
},
},
options: {

View file

@ -172,7 +172,6 @@
"@kbn/aiops-log-rate-analysis",
"@kbn/apm-data-view",
"@kbn/core-saved-objects-api-server",
"@kbn/esql-utils",
"@kbn/search-types",
"@kbn/analytics-ftr-helpers-plugin",
"@kbn/reporting-server",