Skip to content

Commit cfc65dd

Browse files
authored
Index pattern class - remove unused methods (#78538) (#78603)
* remove unused methods
1 parent 943fc14 commit cfc65dd

10 files changed

+11
-66
lines changed

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.addscriptedfield.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Add scripted field to field list
99
<b>Signature:</b>
1010

1111
```typescript
12-
addScriptedField(name: string, script: string, fieldType?: string, lang?: string): Promise<void>;
12+
addScriptedField(name: string, script: string, fieldType?: string): Promise<void>;
1313
```
1414

1515
## Parameters
@@ -19,7 +19,6 @@ addScriptedField(name: string, script: string, fieldType?: string, lang?: string
1919
| name | <code>string</code> | |
2020
| script | <code>string</code> | |
2121
| fieldType | <code>string</code> | |
22-
| lang | <code>string</code> | |
2322

2423
<b>Returns:</b>
2524

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.istimebasedwildcard.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export declare class IndexPattern implements IIndexPattern
4141
4242
| Method | Modifiers | Description |
4343
| --- | --- | --- |
44-
| [addScriptedField(name, script, fieldType, lang)](./kibana-plugin-plugins-data-public.indexpattern.addscriptedfield.md) | | Add scripted field to field list |
44+
| [addScriptedField(name, script, fieldType)](./kibana-plugin-plugins-data-public.indexpattern.addscriptedfield.md) | | Add scripted field to field list |
4545
| [getAggregationRestrictions()](./kibana-plugin-plugins-data-public.indexpattern.getaggregationrestrictions.md) | | |
4646
| [getAsSavedObjectBody()](./kibana-plugin-plugins-data-public.indexpattern.getassavedobjectbody.md) | | Returns index pattern as saved object body for saving |
4747
| [getComputedFields()](./kibana-plugin-plugins-data-public.indexpattern.getcomputedfields.md) | | |
@@ -53,7 +53,6 @@ export declare class IndexPattern implements IIndexPattern
5353
| [getSourceFiltering()](./kibana-plugin-plugins-data-public.indexpattern.getsourcefiltering.md) | | Get the source filtering configuration for that index. |
5454
| [getTimeField()](./kibana-plugin-plugins-data-public.indexpattern.gettimefield.md) | | |
5555
| [isTimeBased()](./kibana-plugin-plugins-data-public.indexpattern.istimebased.md) | | |
56-
| [isTimeBasedWildcard()](./kibana-plugin-plugins-data-public.indexpattern.istimebasedwildcard.md) | | |
5756
| [isTimeNanosBased()](./kibana-plugin-plugins-data-public.indexpattern.istimenanosbased.md) | | |
5857
| [isUnsupportedTimePattern()](./kibana-plugin-plugins-data-public.indexpattern.isunsupportedtimepattern.md) | | |
5958
| [popularizeField(fieldName, unit)](./kibana-plugin-plugins-data-public.indexpattern.popularizefield.md) | | |

docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.addscriptedfield.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Add scripted field to field list
99
<b>Signature:</b>
1010

1111
```typescript
12-
addScriptedField(name: string, script: string, fieldType?: string, lang?: string): Promise<void>;
12+
addScriptedField(name: string, script: string, fieldType?: string): Promise<void>;
1313
```
1414

1515
## Parameters
@@ -19,7 +19,6 @@ addScriptedField(name: string, script: string, fieldType?: string, lang?: string
1919
| name | <code>string</code> | |
2020
| script | <code>string</code> | |
2121
| fieldType | <code>string</code> | |
22-
| lang | <code>string</code> | |
2322

2423
<b>Returns:</b>
2524

docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.istimebasedwildcard.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export declare class IndexPattern implements IIndexPattern
4141
4242
| Method | Modifiers | Description |
4343
| --- | --- | --- |
44-
| [addScriptedField(name, script, fieldType, lang)](./kibana-plugin-plugins-data-server.indexpattern.addscriptedfield.md) | | Add scripted field to field list |
44+
| [addScriptedField(name, script, fieldType)](./kibana-plugin-plugins-data-server.indexpattern.addscriptedfield.md) | | Add scripted field to field list |
4545
| [getAggregationRestrictions()](./kibana-plugin-plugins-data-server.indexpattern.getaggregationrestrictions.md) | | |
4646
| [getAsSavedObjectBody()](./kibana-plugin-plugins-data-server.indexpattern.getassavedobjectbody.md) | | Returns index pattern as saved object body for saving |
4747
| [getComputedFields()](./kibana-plugin-plugins-data-server.indexpattern.getcomputedfields.md) | | |
@@ -53,7 +53,6 @@ export declare class IndexPattern implements IIndexPattern
5353
| [getSourceFiltering()](./kibana-plugin-plugins-data-server.indexpattern.getsourcefiltering.md) | | Get the source filtering configuration for that index. |
5454
| [getTimeField()](./kibana-plugin-plugins-data-server.indexpattern.gettimefield.md) | | |
5555
| [isTimeBased()](./kibana-plugin-plugins-data-server.indexpattern.istimebased.md) | | |
56-
| [isTimeBasedWildcard()](./kibana-plugin-plugins-data-server.indexpattern.istimebasedwildcard.md) | | |
5756
| [isTimeNanosBased()](./kibana-plugin-plugins-data-server.indexpattern.istimenanosbased.md) | | |
5857
| [isUnsupportedTimePattern()](./kibana-plugin-plugins-data-server.indexpattern.isunsupportedtimepattern.md) | | |
5958
| [popularizeField(fieldName, unit)](./kibana-plugin-plugins-data-server.indexpattern.popularizefield.md) | | |

src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ describe('IndexPattern', () => {
179179
await indexPattern.addScriptedField(
180180
scriptedField.name,
181181
scriptedField.script,
182-
scriptedField.type,
183-
'lang'
182+
scriptedField.type
184183
);
185184

186185
const scriptedFields = indexPattern.getScriptedFields();
@@ -206,7 +205,7 @@ describe('IndexPattern', () => {
206205
const scriptedField = last(scriptedFields) as any;
207206
expect.assertions(1);
208207
try {
209-
await indexPattern.addScriptedField(scriptedField.name, "'new script'", 'string', 'lang');
208+
await indexPattern.addScriptedField(scriptedField.name, "'new script'", 'string');
210209
} catch (e) {
211210
expect(e).toBeInstanceOf(DuplicateField);
212211
}

src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,7 @@ export class IndexPattern implements IIndexPattern {
234234
* @param fieldType
235235
* @param lang
236236
*/
237-
async addScriptedField(
238-
name: string,
239-
script: string,
240-
fieldType: string = 'string',
241-
lang: string = 'painless'
242-
) {
237+
async addScriptedField(name: string, script: string, fieldType: string = 'string') {
243238
const scriptedFields = this.getScriptedFields();
244239
const names = _.map(scriptedFields, 'name');
245240

@@ -252,7 +247,7 @@ export class IndexPattern implements IIndexPattern {
252247
script,
253248
type: fieldType,
254249
scripted: true,
255-
lang,
250+
lang: 'painless',
256251
aggregatable: true,
257252
searchable: true,
258253
count: 0,
@@ -345,13 +340,9 @@ export class IndexPattern implements IIndexPattern {
345340
return timeField && timeField.esTypes && timeField.esTypes.indexOf('date_nanos') !== -1;
346341
}
347342

348-
isTimeBasedWildcard(): boolean {
349-
return this.isTimeBased() && this.isWildcard();
350-
}
351-
352343
getTimeField() {
353344
if (!this.timeFieldName || !this.fields || !this.fields.getByName) return undefined;
354-
return this.fields.getByName(this.timeFieldName) || undefined;
345+
return this.fields.getByName(this.timeFieldName);
355346
}
356347

357348
getFieldByName(name: string): IndexPatternField | undefined {
@@ -363,13 +354,6 @@ export class IndexPattern implements IIndexPattern {
363354
return this.typeMeta?.aggs;
364355
}
365356

366-
/**
367-
* Does this index pattern title include a '*'
368-
*/
369-
private isWildcard() {
370-
return _.includes(this.title, '*');
371-
}
372-
373357
/**
374358
* Returns index pattern as saved object body for saving
375359
*/

src/plugins/data/public/public.api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ export type IMetricAggType = MetricAggType;
10881088
export class IndexPattern implements IIndexPattern {
10891089
// Warning: (ae-forgotten-export) The symbol "IndexPatternDeps" needs to be exported by the entry point index.d.ts
10901090
constructor({ spec, savedObjectsClient, fieldFormats, shortDotsEnable, metaFields, }: IndexPatternDeps);
1091-
addScriptedField(name: string, script: string, fieldType?: string, lang?: string): Promise<void>;
1091+
addScriptedField(name: string, script: string, fieldType?: string): Promise<void>;
10921092
// (undocumented)
10931093
fieldFormatMap: Record<string, any>;
10941094
// (undocumented)
@@ -1163,8 +1163,6 @@ export class IndexPattern implements IIndexPattern {
11631163
// (undocumented)
11641164
isTimeBased(): boolean;
11651165
// (undocumented)
1166-
isTimeBasedWildcard(): boolean;
1167-
// (undocumented)
11681166
isTimeNanosBased(): boolean;
11691167
// (undocumented)
11701168
isUnsupportedTimePattern(): boolean;

src/plugins/data/server/server.api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ export type IMetricAggType = MetricAggType;
623623
export class IndexPattern implements IIndexPattern {
624624
// Warning: (ae-forgotten-export) The symbol "IndexPatternDeps" needs to be exported by the entry point index.d.ts
625625
constructor({ spec, savedObjectsClient, fieldFormats, shortDotsEnable, metaFields, }: IndexPatternDeps);
626-
addScriptedField(name: string, script: string, fieldType?: string, lang?: string): Promise<void>;
626+
addScriptedField(name: string, script: string, fieldType?: string): Promise<void>;
627627
// (undocumented)
628628
fieldFormatMap: Record<string, any>;
629629
// Warning: (ae-forgotten-export) The symbol "IIndexPatternFieldList" needs to be exported by the entry point index.d.ts
@@ -702,8 +702,6 @@ export class IndexPattern implements IIndexPattern {
702702
// (undocumented)
703703
isTimeBased(): boolean;
704704
// (undocumented)
705-
isTimeBasedWildcard(): boolean;
706-
// (undocumented)
707705
isTimeNanosBased(): boolean;
708706
// (undocumented)
709707
isUnsupportedTimePattern(): boolean;

0 commit comments

Comments
 (0)