[Chore] Rename field_caps filter-param to indexFilter (#147480)

Field-caps API
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html
has an `index_filter` param, which Kibana is calling `filter`.

Renaming to `indexFilter` for consistency, to avoid confusion.

Main reason for putting up this PR was to help identify usage of
`index_filter`-param of field-caps in the code-base.
This commit is contained in:
Thomas Neirynck 2022-12-14 17:17:51 -05:00 committed by GitHub
parent 6a1b37e5fd
commit 985e58125e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 25 additions and 20 deletions

View file

@ -502,7 +502,7 @@ export class DataViewsService {
type: options.type,
rollupIndex: options.rollupIndex,
allowNoIndex: options.allowNoIndex,
filter: options.filter,
indexFilter: options.indexFilter,
});
return fields;
};
@ -543,7 +543,7 @@ export class DataViewsService {
type: options.type,
rollupIndex: options.rollupIndex,
allowNoIndex: options.allowNoIndex,
filter: options.filter,
indexFilter: options.indexFilter,
});
};

View file

@ -313,7 +313,7 @@ export interface GetFieldsOptions {
metaFields?: string[];
rollupIndex?: string;
allowNoIndex?: boolean;
filter?: QueryDslQueryContainer;
indexFilter?: QueryDslQueryContainer;
includeUnmapped?: boolean;
}

View file

@ -49,7 +49,7 @@ export class DataViewsApiClient implements IDataViewsApiClient {
* @param options options for fields request
*/
getFieldsForWildcard(options: GetFieldsOptions) {
const { pattern, metaFields, type, rollupIndex, allowNoIndex, filter, includeUnmapped } =
const { pattern, metaFields, type, rollupIndex, allowNoIndex, indexFilter, includeUnmapped } =
options;
return this._request<FieldsForWildcardResponse>(
this._getUrl(['_fields_for_wildcard']),
@ -61,7 +61,7 @@ export class DataViewsApiClient implements IDataViewsApiClient {
allow_no_index: allowNoIndex,
include_unmapped: includeUnmapped,
},
filter ? JSON.stringify({ index_filter: filter }) : undefined
indexFilter ? JSON.stringify({ index_filter: indexFilter }) : undefined
).then((response) => {
return response || { fields: [], indices: [] };
});

View file

@ -60,9 +60,9 @@ export class IndexPatternsFetcher {
fieldCapsOptions?: { allow_no_indices: boolean; includeUnmapped?: boolean };
type?: string;
rollupIndex?: string;
filter?: QueryDslQueryContainer;
indexFilter?: QueryDslQueryContainer;
}): Promise<{ fields: FieldDescriptor[]; indices: string[] }> {
const { pattern, metaFields = [], fieldCapsOptions, type, rollupIndex, filter } = options;
const { pattern, metaFields = [], fieldCapsOptions, type, rollupIndex, indexFilter } = options;
const patternList = Array.isArray(pattern) ? pattern : pattern.split(',');
const allowNoIndices = fieldCapsOptions
? fieldCapsOptions.allow_no_indices
@ -80,7 +80,7 @@ export class IndexPatternsFetcher {
allow_no_indices: allowNoIndices,
include_unmapped: fieldCapsOptions?.includeUnmapped,
},
filter,
indexFilter,
});
if (type === 'rollup' && rollupIndex) {
const rollupFields: FieldDescriptor[] = [];

View file

@ -43,7 +43,7 @@ interface FieldCapsApiParams {
callCluster: ElasticsearchClient;
indices: string[] | string;
fieldCapsOptions?: { allow_no_indices: boolean; include_unmapped?: boolean };
filter?: QueryDslQueryContainer;
indexFilter?: QueryDslQueryContainer;
}
/**
@ -62,7 +62,7 @@ export async function callFieldCapsApi(params: FieldCapsApiParams) {
const {
callCluster,
indices,
filter,
indexFilter,
fieldCapsOptions = {
allow_no_indices: false,
include_unmapped: false,
@ -74,7 +74,7 @@ export async function callFieldCapsApi(params: FieldCapsApiParams) {
index: indices,
fields: '*',
ignore_unavailable: true,
index_filter: filter,
index_filter: indexFilter,
...fieldCapsOptions,
},
{ meta: true }

View file

@ -35,7 +35,7 @@ describe('index_patterns/field_capabilities/field_capabilities', () => {
callCluster: undefined,
indices: undefined,
fieldCapsOptions: undefined,
filter: undefined,
indexFilter: undefined,
...args,
});

View file

@ -20,7 +20,7 @@ interface FieldCapabilitiesParams {
indices: string | string[];
metaFields: string[];
fieldCapsOptions?: { allow_no_indices: boolean; include_unmapped?: boolean };
filter?: QueryDslQueryContainer;
indexFilter?: QueryDslQueryContainer;
}
/**
@ -34,8 +34,13 @@ interface FieldCapabilitiesParams {
* @return {Promise<{ fields: Array<FieldDescriptor>, indices: Array<string>>}>}
*/
export async function getFieldCapabilities(params: FieldCapabilitiesParams) {
const { callCluster, indices = [], fieldCapsOptions, filter, metaFields = [] } = params;
const esFieldCaps = await callFieldCapsApi({ callCluster, indices, fieldCapsOptions, filter });
const { callCluster, indices = [], fieldCapsOptions, indexFilter, metaFields = [] } = params;
const esFieldCaps = await callFieldCapsApi({
callCluster,
indices,
fieldCapsOptions,
indexFilter,
});
const fieldsFromFieldCapsByName = keyBy(readFieldCapsResponse(esFieldCaps.body), 'name');
const allFieldsUnsorted = Object.keys(fieldsFromFieldCapsByName)

View file

@ -26,7 +26,7 @@ export class IndexPatternsApiServer implements IDataViewsApiClient {
type,
rollupIndex,
allowNoIndex,
filter,
indexFilter: indexFilter,
}: GetFieldsOptions) {
const indexPatterns = new IndexPatternsFetcher(this.esClient, allowNoIndex);
return await indexPatterns
@ -35,7 +35,7 @@ export class IndexPatternsApiServer implements IDataViewsApiClient {
metaFields,
type,
rollupIndex,
filter,
indexFilter,
})
.catch((err) => {
if (

View file

@ -66,7 +66,7 @@ const handler: RequestHandler<{}, IQuery, IBody> = async (context, request, resp
} = request.query;
// not available to get request
const filter = request.body?.index_filter;
const indexFilter = request.body?.index_filter;
let parsedFields: string[] = [];
try {
@ -85,7 +85,7 @@ const handler: RequestHandler<{}, IQuery, IBody> = async (context, request, resp
allow_no_indices: allowNoIndex || false,
includeUnmapped,
},
filter,
indexFilter,
});
return response.ok({

View file

@ -71,7 +71,7 @@ export async function fetchFieldExistence({
const existingFieldList = await dataViewsService.getFieldsForIndexPattern(dataView, {
// filled in by data views service
pattern: '',
filter: toQuery(timeFieldName, fromDate, toDate, dslQuery),
indexFilter: toQuery(timeFieldName, fromDate, toDate, dslQuery),
});
return {
indexPatternTitle: dataView.title,