[Query] Use a minimal index pattern interface for es query (#102364)

* Move JSON utils to utils package

* Imports from tests

* delete

* split package

* docs

* test

* test

* imports

* minimal index pattern

* move some functions out and use miniaml ip in all es-kuery

* docs

* docs

* rename

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Liza Katz 2021-06-23 22:40:56 +03:00 committed by GitHub
parent 2dc1715a8a
commit 77fe1c1087
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 118 additions and 128 deletions

View file

@ -13,11 +13,11 @@ esFilters: {
FILTERS: typeof FILTERS;
FilterStateStore: typeof FilterStateStore;
buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter;
buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").IIndexPattern) => import("../common").PhrasesFilter;
buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").IIndexPattern) => import("../common").ExistsFilter;
buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").IIndexPattern) => import("../common").PhraseFilter;
buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").MinimalIndexPattern) => import("../common").PhrasesFilter;
buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").MinimalIndexPattern) => import("../common").ExistsFilter;
buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").MinimalIndexPattern) => import("../common").PhraseFilter;
buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter;
buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").IIndexPattern, formattedValue?: string | undefined) => import("../common").RangeFilter;
buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").MinimalIndexPattern, formattedValue?: string | undefined) => import("../common").RangeFilter;
isPhraseFilter: (filter: any) => filter is import("../common").PhraseFilter;
isExistsFilter: (filter: any) => filter is import("../common").ExistsFilter;
isPhrasesFilter: (filter: any) => filter is import("../common").PhrasesFilter;

View file

@ -10,6 +10,6 @@
esKuery: {
nodeTypes: import("../common/es_query/kuery/node_types").NodeTypes;
fromKueryExpression: (expression: any, parseOptions?: Partial<import("../common").KueryParseOptions>) => import("../common").KueryNode;
toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").IIndexPattern | undefined, config?: Record<string, any> | undefined, context?: Record<string, any> | undefined) => import("@kbn/common-utils").JsonObject;
toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").MinimalIndexPattern | undefined, config?: Record<string, any> | undefined, context?: Record<string, any> | undefined) => import("@kbn/common-utils").JsonObject;
}
```

View file

@ -10,7 +10,7 @@
esQuery: {
buildEsQuery: typeof buildEsQuery;
getEsQueryConfig: typeof getEsQueryConfig;
buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").IIndexPattern | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => {
buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").MinimalIndexPattern | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => {
must: never[];
filter: import("../common").Filter[];
should: never[];

View file

@ -1,11 +0,0 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IIndexPattern](./kibana-plugin-plugins-data-public.iindexpattern.md) &gt; [fields](./kibana-plugin-plugins-data-public.iindexpattern.fields.md)
## IIndexPattern.fields property
<b>Signature:</b>
```typescript
fields: IFieldType[];
```

View file

@ -1,11 +0,0 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IIndexPattern](./kibana-plugin-plugins-data-public.iindexpattern.md) &gt; [id](./kibana-plugin-plugins-data-public.iindexpattern.id.md)
## IIndexPattern.id property
<b>Signature:</b>
```typescript
id?: string;
```

View file

@ -12,7 +12,7 @@
<b>Signature:</b>
```typescript
export interface IIndexPattern
export interface IIndexPattern extends MinimalIndexPattern
```
## Properties
@ -20,9 +20,7 @@ export interface IIndexPattern
| Property | Type | Description |
| --- | --- | --- |
| [fieldFormatMap](./kibana-plugin-plugins-data-public.iindexpattern.fieldformatmap.md) | <code>Record&lt;string, SerializedFieldFormat&lt;unknown&gt; &#124; undefined&gt;</code> | |
| [fields](./kibana-plugin-plugins-data-public.iindexpattern.fields.md) | <code>IFieldType[]</code> | |
| [getFormatterForField](./kibana-plugin-plugins-data-public.iindexpattern.getformatterforfield.md) | <code>(field: IndexPatternField &#124; IndexPatternField['spec'] &#124; IFieldType) =&gt; FieldFormat</code> | Look up a formatter for a given field |
| [id](./kibana-plugin-plugins-data-public.iindexpattern.id.md) | <code>string</code> | |
| [timeFieldName](./kibana-plugin-plugins-data-public.iindexpattern.timefieldname.md) | <code>string</code> | |
| [title](./kibana-plugin-plugins-data-public.iindexpattern.title.md) | <code>string</code> | |
| [type](./kibana-plugin-plugins-data-public.iindexpattern.type.md) | <code>string</code> | Type is used for identifying rollup indices, otherwise left undefined |

View file

@ -11,11 +11,11 @@ esFilters: {
buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter;
buildCustomFilter: typeof buildCustomFilter;
buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter;
buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").IIndexPattern) => import("../common").ExistsFilter;
buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").MinimalIndexPattern) => import("../common").ExistsFilter;
buildFilter: typeof buildFilter;
buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").IIndexPattern) => import("../common").PhraseFilter;
buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").IIndexPattern) => import("../common").PhrasesFilter;
buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").IIndexPattern, formattedValue?: string | undefined) => import("../common").RangeFilter;
buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").MinimalIndexPattern) => import("../common").PhraseFilter;
buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").MinimalIndexPattern) => import("../common").PhrasesFilter;
buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").MinimalIndexPattern, formattedValue?: string | undefined) => import("../common").RangeFilter;
isFilterDisabled: (filter: import("../common").Filter) => boolean;
}
```

View file

@ -10,6 +10,6 @@
esKuery: {
nodeTypes: import("../common/es_query/kuery/node_types").NodeTypes;
fromKueryExpression: (expression: any, parseOptions?: Partial<import("../common").KueryParseOptions>) => import("../common").KueryNode;
toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").IIndexPattern | undefined, config?: Record<string, any> | undefined, context?: Record<string, any> | undefined) => import("@kbn/common-utils").JsonObject;
toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").MinimalIndexPattern | undefined, config?: Record<string, any> | undefined, context?: Record<string, any> | undefined) => import("@kbn/common-utils").JsonObject;
}
```

View file

@ -8,7 +8,7 @@
```typescript
esQuery: {
buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").IIndexPattern | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => {
buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").MinimalIndexPattern | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => {
must: never[];
filter: import("../common").Filter[];
should: never[];

View file

@ -10,9 +10,9 @@ import { groupBy, has, isEqual } from 'lodash';
import { buildQueryFromKuery } from './from_kuery';
import { buildQueryFromFilters } from './from_filters';
import { buildQueryFromLucene } from './from_lucene';
import { IIndexPattern } from '../../index_patterns';
import { Filter } from '../filters';
import { Query } from '../../query/types';
import { IndexPatternBase } from './types';
export interface EsQueryConfig {
allowLeadingWildcards: boolean;
@ -36,7 +36,7 @@ function removeMatchAll<T>(filters: T[]) {
* config contains dateformat:tz
*/
export function buildEsQuery(
indexPattern: IIndexPattern | undefined,
indexPattern: IndexPatternBase | undefined,
queries: Query | Query[],
filters: Filter | Filter[],
config: EsQueryConfig = {

View file

@ -6,15 +6,16 @@
* Side Public License, v 1.
*/
import { IIndexPattern, IFieldType } from '../../index_patterns';
import { IFieldType } from '../../index_patterns';
import { Filter } from '../filters';
import { IndexPatternBase } from './types';
/*
* TODO: We should base this on something better than `filter.meta.key`. We should probably modify
* this to check if `filter.meta.index` matches `indexPattern.id` instead, but that's a breaking
* change.
*/
export function filterMatchesIndex(filter: Filter, indexPattern?: IIndexPattern | null) {
export function filterMatchesIndex(filter: Filter, indexPattern?: IndexPatternBase | null) {
if (!filter.meta?.key || !indexPattern) {
return true;
}

View file

@ -10,7 +10,7 @@ import { isUndefined } from 'lodash';
import { migrateFilter } from './migrate_filter';
import { filterMatchesIndex } from './filter_matches_index';
import { Filter, cleanFilter, isFilterDisabled } from '../filters';
import { IIndexPattern } from '../../index_patterns';
import { IndexPatternBase } from './types';
import { handleNestedFilter } from './handle_nested_filter';
/**
@ -45,7 +45,7 @@ const translateToQuery = (filter: Filter) => {
export const buildQueryFromFilters = (
filters: Filter[] = [],
indexPattern: IIndexPattern | undefined,
indexPattern: IndexPatternBase | undefined,
ignoreFilterIfFieldNotInIndex: boolean = false
) => {
filters = filters.filter((filter) => filter && !isFilterDisabled(filter));

View file

@ -7,11 +7,11 @@
*/
import { fromKueryExpression, toElasticsearchQuery, nodeTypes, KueryNode } from '../kuery';
import { IIndexPattern } from '../../index_patterns';
import { IndexPatternBase } from './types';
import { Query } from '../../query/types';
export function buildQueryFromKuery(
indexPattern: IIndexPattern | undefined,
indexPattern: IndexPatternBase | undefined,
queries: Query[] = [],
allowLeadingWildcards: boolean = false,
dateFormatTZ?: string
@ -24,7 +24,7 @@ export function buildQueryFromKuery(
}
function buildQuery(
indexPattern: IIndexPattern | undefined,
indexPattern: IndexPatternBase | undefined,
queryASTs: KueryNode[],
config: Record<string, any> = {}
) {

View file

@ -9,13 +9,14 @@
import { handleNestedFilter } from './handle_nested_filter';
import { fields } from '../../index_patterns/mocks';
import { buildPhraseFilter, buildQueryFilter } from '../filters';
import { IFieldType, IIndexPattern } from '../../index_patterns';
import { IndexPatternBase } from './types';
import { IFieldType } from '../../index_patterns';
describe('handleNestedFilter', function () {
const indexPattern: IIndexPattern = ({
const indexPattern: IndexPatternBase = {
id: 'logstash-*',
fields,
} as unknown) as IIndexPattern;
};
it("should return the filter's query wrapped in nested query if the target field is nested", () => {
const field = getField('nestedField.child');

View file

@ -7,9 +7,9 @@
*/
import { getFilterField, cleanFilter, Filter } from '../filters';
import { IIndexPattern } from '../../index_patterns';
import { IndexPatternBase } from './types';
export const handleNestedFilter = (filter: Filter, indexPattern?: IIndexPattern) => {
export const handleNestedFilter = (filter: Filter, indexPattern?: IndexPatternBase) => {
if (!indexPattern) return filter;
const fieldName = getFilterField(filter);

View file

@ -11,3 +11,4 @@ export { buildQueryFromFilters } from './from_filters';
export { luceneStringToDsl } from './lucene_string_to_dsl';
export { decorateQuery } from './decorate_query';
export { getEsQueryConfig } from './get_es_query_config';
export { IndexPatternBase } from './types';

View file

@ -9,7 +9,7 @@
import { get, omit } from 'lodash';
import { getConvertedValueForField } from '../filters';
import { Filter } from '../filters';
import { IIndexPattern } from '../../index_patterns';
import { IndexPatternBase } from './types';
export interface DeprecatedMatchPhraseFilter extends Filter {
query: {
@ -28,7 +28,7 @@ function isDeprecatedMatchPhraseFilter(filter: any): filter is DeprecatedMatchPh
return Boolean(fieldName && get(filter, ['query', 'match', fieldName, 'type']) === 'phrase');
}
export function migrateFilter(filter: Filter, indexPattern?: IIndexPattern) {
export function migrateFilter(filter: Filter, indexPattern?: IndexPatternBase) {
if (isDeprecatedMatchPhraseFilter(filter)) {
const fieldName = Object.keys(filter.query.match)[0];
const params: Record<string, any> = get(filter, ['query', 'match', fieldName]);

View file

@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { IFieldType } from '../../index_patterns';
export interface IndexPatternBase {
fields: IFieldType[];
id?: string;
}

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { IIndexPattern, IFieldType } from '../..';
import { IFieldType, IndexPatternBase } from '../..';
import {
Filter,
FILTERS,
@ -19,7 +19,7 @@ import {
} from '.';
export function buildFilter(
indexPattern: IIndexPattern,
indexPattern: IndexPatternBase,
field: IFieldType,
type: FILTERS,
negate: boolean,
@ -59,7 +59,7 @@ export function buildCustomFilter(
}
function buildBaseFilter(
indexPattern: IIndexPattern,
indexPattern: IndexPatternBase,
field: IFieldType,
type: FILTERS,
params: any

View file

@ -7,7 +7,8 @@
*/
import { Filter, FilterMeta } from './meta_filter';
import { IIndexPattern, IFieldType } from '../../index_patterns';
import { IFieldType } from '../../index_patterns';
import { IndexPatternBase } from '..';
export type ExistsFilterMeta = FilterMeta;
@ -26,7 +27,7 @@ export const getExistsFilterField = (filter: ExistsFilter) => {
return filter.exists && filter.exists.field;
};
export const buildExistsFilter = (field: IFieldType, indexPattern: IIndexPattern) => {
export const buildExistsFilter = (field: IFieldType, indexPattern: IndexPatternBase) => {
return {
meta: {
index: indexPattern.id,

View file

@ -14,10 +14,8 @@ export * from './custom_filter';
export * from './exists_filter';
export * from './geo_bounding_box_filter';
export * from './geo_polygon_filter';
export * from './get_display_value';
export * from './get_filter_field';
export * from './get_filter_params';
export * from './get_index_pattern_from_filter';
export * from './match_all_filter';
export * from './meta_filter';
export * from './missing_filter';

View file

@ -8,7 +8,8 @@
import type { estypes } from '@elastic/elasticsearch';
import { get, isPlainObject } from 'lodash';
import { Filter, FilterMeta } from './meta_filter';
import { IIndexPattern, IFieldType } from '../../index_patterns';
import { IFieldType } from '../../index_patterns';
import { IndexPatternBase } from '..';
export type PhraseFilterMeta = FilterMeta & {
params?: {
@ -60,7 +61,7 @@ export const getPhraseFilterValue = (filter: PhraseFilter): PhraseFilterValue =>
export const buildPhraseFilter = (
field: IFieldType,
value: any,
indexPattern: IIndexPattern
indexPattern: IndexPatternBase
): PhraseFilter => {
const convertedValue = getConvertedValueForField(field, value);

View file

@ -9,7 +9,8 @@
import { Filter, FilterMeta } from './meta_filter';
import { getPhraseScript } from './phrase_filter';
import { FILTERS } from './index';
import { IIndexPattern, IFieldType } from '../../index_patterns';
import { IFieldType } from '../../index_patterns';
import { IndexPatternBase } from '../es_query';
export type PhrasesFilterMeta = FilterMeta & {
params: string[]; // The unformatted values
@ -34,7 +35,7 @@ export const getPhrasesFilterField = (filter: PhrasesFilter) => {
export const buildPhrasesFilter = (
field: IFieldType,
params: any[],
indexPattern: IIndexPattern
indexPattern: IndexPatternBase
) => {
const index = indexPattern.id;
const type = FILTERS.PHRASES;

View file

@ -8,7 +8,8 @@
import type { estypes } from '@elastic/elasticsearch';
import { map, reduce, mapValues, get, keys, pickBy } from 'lodash';
import { Filter, FilterMeta } from './meta_filter';
import { IIndexPattern, IFieldType } from '../../index_patterns';
import { IFieldType } from '../../index_patterns';
import { IndexPatternBase } from '..';
const OPERANDS_IN_RANGE = 2;
@ -93,7 +94,7 @@ const format = (field: IFieldType, value: any) =>
export const buildRangeFilter = (
field: IFieldType,
params: RangeFilterParams,
indexPattern: IIndexPattern,
indexPattern: IndexPatternBase,
formattedValue?: string
): RangeFilter => {
const filter: any = { meta: { index: indexPattern.id, params: {} } };

View file

@ -10,10 +10,10 @@ import { JsonObject } from '@kbn/common-utils';
import { nodeTypes } from '../node_types/index';
import { KQLSyntaxError } from '../kuery_syntax_error';
import { KueryNode, DslQuery, KueryParseOptions } from '../types';
import { IIndexPattern } from '../../../index_patterns/types';
// @ts-ignore
import { parse as parseKuery } from './_generated_/kuery';
import { IndexPatternBase } from '../..';
const fromExpression = (
expression: string | DslQuery,
@ -65,7 +65,7 @@ export const fromKueryExpression = (
*/
export const toElasticsearchQuery = (
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config?: Record<string, any>,
context?: Record<string, any>
): JsonObject => {

View file

@ -7,7 +7,7 @@
*/
import * as ast from '../ast';
import { IIndexPattern, KueryNode } from '../../..';
import { IndexPatternBase, KueryNode } from '../../..';
export function buildNodeParams(children: KueryNode[]) {
return {
@ -17,7 +17,7 @@ export function buildNodeParams(children: KueryNode[]) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -8,7 +8,7 @@
import { get } from 'lodash';
import * as literal from '../node_types/literal';
import { IIndexPattern, KueryNode, IFieldType } from '../../..';
import { KueryNode, IFieldType, IndexPatternBase } from '../../..';
export function buildNodeParams(fieldName: string) {
return {
@ -18,7 +18,7 @@ export function buildNodeParams(fieldName: string) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -9,7 +9,7 @@
import _ from 'lodash';
import { nodeTypes } from '../node_types';
import * as ast from '../ast';
import { IIndexPattern, KueryNode, IFieldType, LatLon } from '../../..';
import { IndexPatternBase, KueryNode, IFieldType, LatLon } from '../../..';
export function buildNodeParams(fieldName: string, params: any) {
params = _.pick(params, 'topLeft', 'bottomRight');
@ -26,7 +26,7 @@ export function buildNodeParams(fieldName: string, params: any) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -8,7 +8,7 @@
import { nodeTypes } from '../node_types';
import * as ast from '../ast';
import { IIndexPattern, KueryNode, IFieldType, LatLon } from '../../..';
import { IndexPatternBase, KueryNode, IFieldType, LatLon } from '../../..';
import { LiteralTypeBuildNode } from '../node_types/types';
export function buildNodeParams(fieldName: string, points: LatLon[]) {
@ -25,7 +25,7 @@ export function buildNodeParams(fieldName: string, points: LatLon[]) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -11,7 +11,7 @@ import { getPhraseScript } from '../../filters';
import { getFields } from './utils/get_fields';
import { getTimeZoneFromSettings } from '../../utils';
import { getFullFieldNameNode } from './utils/get_full_field_name_node';
import { IIndexPattern, KueryNode, IFieldType } from '../../..';
import { IndexPatternBase, KueryNode, IFieldType } from '../../..';
import * as ast from '../ast';
@ -39,7 +39,7 @@ export function buildNodeParams(fieldName: string, value: any, isPhrase: boolean
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -8,7 +8,7 @@
import * as ast from '../ast';
import * as literal from '../node_types/literal';
import { IIndexPattern, KueryNode } from '../../..';
import { IndexPatternBase, KueryNode } from '../../..';
export function buildNodeParams(path: any, child: any) {
const pathNode =
@ -20,7 +20,7 @@ export function buildNodeParams(path: any, child: any) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -7,7 +7,7 @@
*/
import * as ast from '../ast';
import { IIndexPattern, KueryNode } from '../../..';
import { IndexPatternBase, KueryNode } from '../../..';
export function buildNodeParams(child: KueryNode) {
return {
@ -17,7 +17,7 @@ export function buildNodeParams(child: KueryNode) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -7,7 +7,7 @@
*/
import * as ast from '../ast';
import { IIndexPattern, KueryNode } from '../../..';
import { IndexPatternBase, KueryNode } from '../../..';
export function buildNodeParams(children: KueryNode[]) {
return {
@ -17,7 +17,7 @@ export function buildNodeParams(children: KueryNode[]) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -13,7 +13,7 @@ import { getRangeScript, RangeFilterParams } from '../../filters';
import { getFields } from './utils/get_fields';
import { getTimeZoneFromSettings } from '../../utils';
import { getFullFieldNameNode } from './utils/get_full_field_name_node';
import { IIndexPattern, KueryNode, IFieldType } from '../../..';
import { IndexPatternBase, KueryNode, IFieldType } from '../../..';
export function buildNodeParams(fieldName: string, params: RangeFilterParams) {
const paramsToMap = _.pick(params, 'gt', 'lt', 'gte', 'lte', 'format');
@ -33,7 +33,7 @@ export function buildNodeParams(fieldName: string, params: RangeFilterParams) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
context: Record<string, any> = {}
) {

View file

@ -8,10 +8,10 @@
import * as literal from '../../node_types/literal';
import * as wildcard from '../../node_types/wildcard';
import { KueryNode, IIndexPattern } from '../../../..';
import { KueryNode, IndexPatternBase } from '../../../..';
import { LiteralTypeBuildNode } from '../../node_types/types';
export function getFields(node: KueryNode, indexPattern?: IIndexPattern) {
export function getFields(node: KueryNode, indexPattern?: IndexPatternBase) {
if (!indexPattern) return [];
if (node.type === 'literal') {
const fieldName = literal.toElasticsearchQuery(node as LiteralTypeBuildNode);

View file

@ -7,11 +7,11 @@
*/
import { getFields } from './get_fields';
import { IIndexPattern, IFieldType, KueryNode } from '../../../..';
import { IndexPatternBase, IFieldType, KueryNode } from '../../../..';
export function getFullFieldNameNode(
rootNameNode: any,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
nestedPath?: string
): KueryNode {
const fullFieldNameNode = {

View file

@ -9,7 +9,7 @@
import _ from 'lodash';
import { functions } from '../functions';
import { IIndexPattern, KueryNode } from '../../..';
import { IndexPatternBase, KueryNode } from '../../..';
import { FunctionName, FunctionTypeBuildNode } from './types';
export function buildNode(functionName: FunctionName, ...args: any[]) {
@ -45,7 +45,7 @@ export function buildNodeWithArgumentNodes(
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config?: Record<string, any>,
context?: Record<string, any>
) {

View file

@ -11,8 +11,8 @@
*/
import { JsonValue } from '@kbn/common-utils';
import { IIndexPattern } from '../../../index_patterns';
import { KueryNode } from '..';
import { IndexPatternBase } from '../..';
export type FunctionName =
| 'is'
@ -30,7 +30,7 @@ interface FunctionType {
buildNodeWithArgumentNodes: (functionName: FunctionName, args: any[]) => FunctionTypeBuildNode;
toElasticsearchQuery: (
node: any,
indexPattern?: IIndexPattern,
indexPattern?: IndexPatternBase,
config?: Record<string, any>,
context?: Record<string, any>
) => JsonValue;

View file

@ -9,6 +9,7 @@ import type { estypes } from '@elastic/elasticsearch';
import { ToastInputFields, ErrorToastOptions } from 'src/core/public/notifications';
// eslint-disable-next-line
import type { SavedObject } from 'src/core/server';
import type { IndexPatternBase } from '../es_query';
import { IFieldType } from './fields';
import { RUNTIME_FIELD_TYPES } from './constants';
import { SerializedFieldFormat } from '../../../expressions/common';
@ -29,10 +30,8 @@ export interface RuntimeField {
* IIndexPattern allows for an IndexPattern OR an index pattern saved object
* Use IndexPattern or IndexPatternSpec instead
*/
export interface IIndexPattern {
fields: IFieldType[];
export interface IIndexPattern extends IndexPatternBase {
title: string;
id?: string;
/**
* Type is used for identifying rollup indices, otherwise left undefined
*/

View file

@ -23,7 +23,6 @@ import {
disableFilter,
FILTERS,
FilterStateStore,
getDisplayValueFromFilter,
getPhraseFilterField,
getPhraseFilterValue,
isExistsFilter,
@ -43,6 +42,7 @@ import { FilterLabel } from './ui';
import { FilterItem } from './ui/filter_bar';
import {
getDisplayValueFromFilter,
generateFilters,
onlyDisabledFiltersChanged,
changeTimeFilter,

View file

@ -808,11 +808,11 @@ export const esFilters: {
FILTERS: typeof FILTERS;
FilterStateStore: typeof FilterStateStore;
buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter;
buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").IIndexPattern) => import("../common").PhrasesFilter;
buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").IIndexPattern) => import("../common").ExistsFilter;
buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").IIndexPattern) => import("../common").PhraseFilter;
buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter;
buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter;
buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter;
buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter;
buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").IIndexPattern, formattedValue?: string | undefined) => import("../common").RangeFilter;
buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter;
isPhraseFilter: (filter: any) => filter is import("../common").PhraseFilter;
isExistsFilter: (filter: any) => filter is import("../common").ExistsFilter;
isPhrasesFilter: (filter: any) => filter is import("../common").PhrasesFilter;
@ -858,7 +858,7 @@ export const esFilters: {
export const esKuery: {
nodeTypes: import("../common/es_query/kuery/node_types").NodeTypes;
fromKueryExpression: (expression: any, parseOptions?: Partial<import("../common").KueryParseOptions>) => import("../common").KueryNode;
toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").IIndexPattern | undefined, config?: Record<string, any> | undefined, context?: Record<string, any> | undefined) => import("@kbn/common-utils").JsonObject;
toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").IndexPatternBase | undefined, config?: Record<string, any> | undefined, context?: Record<string, any> | undefined) => import("@kbn/common-utils").JsonObject;
};
// Warning: (ae-missing-release-tag) "esQuery" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@ -867,7 +867,7 @@ export const esKuery: {
export const esQuery: {
buildEsQuery: typeof buildEsQuery;
getEsQueryConfig: typeof getEsQueryConfig;
buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").IIndexPattern | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => {
buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").IndexPatternBase | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => {
must: never[];
filter: import("../common").Filter[];
should: never[];
@ -1286,22 +1286,19 @@ export interface IFieldType {
visualizable?: boolean;
}
// Warning: (ae-forgotten-export) The symbol "IndexPatternBase" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "IIndexPattern" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public @deprecated (undocumented)
export interface IIndexPattern {
export interface IIndexPattern extends IndexPatternBase {
// Warning: (ae-forgotten-export) The symbol "SerializedFieldFormat" needs to be exported by the entry point index.d.ts
//
// (undocumented)
fieldFormatMap?: Record<string, SerializedFieldFormat<unknown> | undefined>;
// (undocumented)
fields: IFieldType[];
getFormatterForField?: (field: IndexPatternField | IndexPatternField['spec'] | IFieldType) => FieldFormat;
// (undocumented)
getTimeField?(): IFieldType | undefined;
// (undocumented)
id?: string;
// (undocumented)
timeFieldName?: string;
// (undocumented)
title: string;
@ -2731,13 +2728,13 @@ export interface WaitUntilNextSessionCompletesOptions {
// Warnings were encountered during analysis:
//
// src/plugins/data/common/es_query/filters/exists_filter.ts:19:3 - (ae-forgotten-export) The symbol "ExistsFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/exists_filter.ts:20:3 - (ae-forgotten-export) The symbol "FilterExistsProperty" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/exists_filter.ts:20:3 - (ae-forgotten-export) The symbol "ExistsFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/exists_filter.ts:21:3 - (ae-forgotten-export) The symbol "FilterExistsProperty" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/match_all_filter.ts:17:3 - (ae-forgotten-export) The symbol "MatchAllFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/meta_filter.ts:43:3 - (ae-forgotten-export) The symbol "FilterState" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/meta_filter.ts:44:3 - (ae-forgotten-export) The symbol "FilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/phrase_filter.ts:22:3 - (ae-forgotten-export) The symbol "PhraseFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/phrases_filter.ts:20:3 - (ae-forgotten-export) The symbol "PhrasesFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/phrase_filter.ts:23:3 - (ae-forgotten-export) The symbol "PhraseFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/es_query/filters/phrases_filter.ts:21:3 - (ae-forgotten-export) The symbol "PhrasesFilterMeta" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:65:5 - (ae-forgotten-export) The symbol "FormatFieldFn" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:138:7 - (ae-forgotten-export) The symbol "FieldAttrSet" needs to be exported by the entry point index.d.ts
// src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts:169:7 - (ae-forgotten-export) The symbol "RuntimeField" needs to be exported by the entry point index.d.ts

View file

@ -11,3 +11,5 @@ export { FilterManager } from './filter_manager';
export { mapAndFlattenFilters } from './lib/map_and_flatten_filters';
export { onlyDisabledFiltersChanged } from './lib/only_disabled';
export { generateFilters } from './lib/generate_filters';
export { getDisplayValueFromFilter } from './lib/get_display_value';
export { getIndexPatternFromFilter } from './lib/get_index_pattern_from_filter';

View file

@ -7,9 +7,8 @@
*/
import { i18n } from '@kbn/i18n';
import { IIndexPattern } from '../..';
import { Filter, IIndexPattern } from '../../../../common';
import { getIndexPatternFromFilter } from './get_index_pattern_from_filter';
import { Filter } from '../filters';
function getValueFormatter(indexPattern?: IIndexPattern, key?: string) {
// checking getFormatterForField exists because there is at least once case where an index pattern

View file

@ -6,8 +6,7 @@
* Side Public License, v 1.
*/
import { Filter } from '../filters';
import { IIndexPattern } from '../..';
import { Filter, IIndexPattern } from '../../../../common';
export function getIndexPatternFromFilter(
filter: Filter,

View file

@ -20,9 +20,9 @@ import {
import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component } from 'react';
import { IIndexPattern } from '../..';
import { getDisplayValueFromFilter, Filter } from '../../../common';
import { Filter } from '../../../common';
import { FilterLabel } from '../filter_bar';
import { mapAndFlattenFilters } from '../../query';
import { mapAndFlattenFilters, getDisplayValueFromFilter } from '../../query';
interface Props {
filters: Filter[];

View file

@ -37,10 +37,10 @@ import { Operator } from './lib/filter_operators';
import { PhraseValueInput } from './phrase_value_input';
import { PhrasesValuesInput } from './phrases_values_input';
import { RangeValueInput } from './range_value_input';
import { getIndexPatternFromFilter } from '../../../query';
import { IIndexPattern, IFieldType } from '../../..';
import {
Filter,
getIndexPatternFromFilter,
FieldFilter,
buildFilter,
buildCustomFilter,

View file

@ -14,14 +14,13 @@ import { IUiSettingsClient } from 'src/core/public';
import { FilterEditor } from './filter_editor';
import { FilterView } from './filter_view';
import { IIndexPattern } from '../..';
import { getDisplayValueFromFilter, getIndexPatternFromFilter } from '../../query';
import {
Filter,
isFilterPinned,
getDisplayValueFromFilter,
toggleFilterNegated,
toggleFilterPinned,
toggleFilterDisabled,
getIndexPatternFromFilter,
} from '../../../common';
import { getIndexPatterns } from '../../services';

View file

@ -447,11 +447,11 @@ export const esFilters: {
buildQueryFilter: (query: any, index: string, alias: string) => import("../common").QueryStringFilter;
buildCustomFilter: typeof buildCustomFilter;
buildEmptyFilter: (isPinned: boolean, index?: string | undefined) => import("../common").Filter;
buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").IIndexPattern) => import("../common").ExistsFilter;
buildExistsFilter: (field: import("../common").IFieldType, indexPattern: import("../common").IndexPatternBase) => import("../common").ExistsFilter;
buildFilter: typeof buildFilter;
buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").IIndexPattern) => import("../common").PhraseFilter;
buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").IIndexPattern) => import("../common").PhrasesFilter;
buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").IIndexPattern, formattedValue?: string | undefined) => import("../common").RangeFilter;
buildPhraseFilter: (field: import("../common").IFieldType, value: any, indexPattern: import("../common").IndexPatternBase) => import("../common").PhraseFilter;
buildPhrasesFilter: (field: import("../common").IFieldType, params: any[], indexPattern: import("../common").IndexPatternBase) => import("../common").PhrasesFilter;
buildRangeFilter: (field: import("../common").IFieldType, params: import("../common").RangeFilterParams, indexPattern: import("../common").IndexPatternBase, formattedValue?: string | undefined) => import("../common").RangeFilter;
isFilterDisabled: (filter: import("../common").Filter) => boolean;
};
@ -461,14 +461,14 @@ export const esFilters: {
export const esKuery: {
nodeTypes: import("../common/es_query/kuery/node_types").NodeTypes;
fromKueryExpression: (expression: any, parseOptions?: Partial<import("../common").KueryParseOptions>) => import("../common").KueryNode;
toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").IIndexPattern | undefined, config?: Record<string, any> | undefined, context?: Record<string, any> | undefined) => import("@kbn/common-utils").JsonObject;
toElasticsearchQuery: (node: import("../common").KueryNode, indexPattern?: import("../common").IndexPatternBase | undefined, config?: Record<string, any> | undefined, context?: Record<string, any> | undefined) => import("@kbn/common-utils").JsonObject;
};
// Warning: (ae-missing-release-tag) "esQuery" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const esQuery: {
buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").IIndexPattern | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => {
buildQueryFromFilters: (filters: import("../common").Filter[] | undefined, indexPattern: import("../common").IndexPatternBase | undefined, ignoreFilterIfFieldNotInIndex?: boolean) => {
must: never[];
filter: import("../common").Filter[];
should: never[];