Skip to content

Commit

Permalink
Merge branch 'master' into improve-page-load-axis
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Sep 28, 2020
2 parents a92a6bc + db78d70 commit ee7b238
Show file tree
Hide file tree
Showing 40 changed files with 529 additions and 410 deletions.
4 changes: 2 additions & 2 deletions docs/developer/advanced/development-basepath.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ You can set this explicitly using `server.basePath` in <<settings>>.

Use the server.rewriteBasePath setting to tell {kib} if it should remove the basePath from requests it receives, and to prevent a deprecation warning at startup. This setting cannot end in a slash (/).

If you want to turn off the basepath when in development mode, start {kib} with the `--no-basepath` flag
If you want to turn off the basepath when in development mode, start {kib} with the `--no-base-path` flag

[source,bash]
----
yarn start --no-basepath
yarn start --no-base-path
----


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Add scripted field to field list
<b>Signature:</b>

```typescript
addScriptedField(name: string, script: string, fieldType?: string, lang?: string): Promise<void>;
addScriptedField(name: string, script: string, fieldType?: string): Promise<void>;
```

## Parameters
Expand All @@ -19,7 +19,6 @@ addScriptedField(name: string, script: string, fieldType?: string, lang?: string
| name | <code>string</code> | |
| script | <code>string</code> | |
| fieldType | <code>string</code> | |
| lang | <code>string</code> | |

<b>Returns:</b>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export declare class IndexPattern implements IIndexPattern
| Method | Modifiers | Description |
| --- | --- | --- |
| [addScriptedField(name, script, fieldType, lang)](./kibana-plugin-plugins-data-public.indexpattern.addscriptedfield.md) | | Add scripted field to field list |
| [addScriptedField(name, script, fieldType)](./kibana-plugin-plugins-data-public.indexpattern.addscriptedfield.md) | | Add scripted field to field list |
| [getAggregationRestrictions()](./kibana-plugin-plugins-data-public.indexpattern.getaggregationrestrictions.md) | | |
| [getAsSavedObjectBody()](./kibana-plugin-plugins-data-public.indexpattern.getassavedobjectbody.md) | | Returns index pattern as saved object body for saving |
| [getComputedFields()](./kibana-plugin-plugins-data-public.indexpattern.getcomputedfields.md) | | |
Expand All @@ -52,7 +52,6 @@ export declare class IndexPattern implements IIndexPattern
| [getSourceFiltering()](./kibana-plugin-plugins-data-public.indexpattern.getsourcefiltering.md) | | Get the source filtering configuration for that index. |
| [getTimeField()](./kibana-plugin-plugins-data-public.indexpattern.gettimefield.md) | | |
| [isTimeBased()](./kibana-plugin-plugins-data-public.indexpattern.istimebased.md) | | |
| [isTimeBasedWildcard()](./kibana-plugin-plugins-data-public.indexpattern.istimebasedwildcard.md) | | |
| [isTimeNanosBased()](./kibana-plugin-plugins-data-public.indexpattern.istimenanosbased.md) | | |
| [popularizeField(fieldName, unit)](./kibana-plugin-plugins-data-public.indexpattern.popularizefield.md) | | |
| [removeScriptedField(fieldName)](./kibana-plugin-plugins-data-public.indexpattern.removescriptedfield.md) | | Remove scripted field from field list |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Add scripted field to field list
<b>Signature:</b>

```typescript
addScriptedField(name: string, script: string, fieldType?: string, lang?: string): Promise<void>;
addScriptedField(name: string, script: string, fieldType?: string): Promise<void>;
```

## Parameters
Expand All @@ -19,7 +19,6 @@ addScriptedField(name: string, script: string, fieldType?: string, lang?: string
| name | <code>string</code> | |
| script | <code>string</code> | |
| fieldType | <code>string</code> | |
| lang | <code>string</code> | |

<b>Returns:</b>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export declare class IndexPattern implements IIndexPattern
| Method | Modifiers | Description |
| --- | --- | --- |
| [addScriptedField(name, script, fieldType, lang)](./kibana-plugin-plugins-data-server.indexpattern.addscriptedfield.md) | | Add scripted field to field list |
| [addScriptedField(name, script, fieldType)](./kibana-plugin-plugins-data-server.indexpattern.addscriptedfield.md) | | Add scripted field to field list |
| [getAggregationRestrictions()](./kibana-plugin-plugins-data-server.indexpattern.getaggregationrestrictions.md) | | |
| [getAsSavedObjectBody()](./kibana-plugin-plugins-data-server.indexpattern.getassavedobjectbody.md) | | Returns index pattern as saved object body for saving |
| [getComputedFields()](./kibana-plugin-plugins-data-server.indexpattern.getcomputedfields.md) | | |
Expand All @@ -52,7 +52,6 @@ export declare class IndexPattern implements IIndexPattern
| [getSourceFiltering()](./kibana-plugin-plugins-data-server.indexpattern.getsourcefiltering.md) | | Get the source filtering configuration for that index. |
| [getTimeField()](./kibana-plugin-plugins-data-server.indexpattern.gettimefield.md) | | |
| [isTimeBased()](./kibana-plugin-plugins-data-server.indexpattern.istimebased.md) | | |
| [isTimeBasedWildcard()](./kibana-plugin-plugins-data-server.indexpattern.istimebasedwildcard.md) | | |
| [isTimeNanosBased()](./kibana-plugin-plugins-data-server.indexpattern.istimenanosbased.md) | | |
| [popularizeField(fieldName, unit)](./kibana-plugin-plugins-data-server.indexpattern.popularizefield.md) | | |
| [removeScriptedField(fieldName)](./kibana-plugin-plugins-data-server.indexpattern.removescriptedfield.md) | | Remove scripted field from field list |
Expand Down
3 changes: 1 addition & 2 deletions docs/getting-started/tutorial-define-index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ index named `shakespeare,` and the accounts data set, which has an index named
. In the *Index pattern name* field, enter `shakes*`.
+
[role="screenshot"]
image::images/tutorial-pattern-1.png[shakes* index patterns]
image::images/tutorial-pattern-1.png[Image showing how to enter shakes* in Index Pattern Name field]

. Click *Next step*.

Expand Down Expand Up @@ -54,4 +54,3 @@ available, open the menu, go to *Dev Tools > Console*, then enter `GET _cat/indi
For Windows, run `Invoke-RestMethod -Uri "http://localhost:9200/_cat/indices"` in Powershell.



Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@
}
},
"my_array": {
"properties": {
"total": {
"type": "number"
},
"type": {
"type": "boolean"
"type": "array",
"items": {
"properties": {
"total": {
"type": "number"
},
"type": {
"type": "boolean"
}
}
}
},
"my_str_array": { "type": "keyword" }
"my_str_array": { "type": "array", "items": { "type": "keyword" } }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ export const parsedWorkingCollector: ParsedUsageCollection = [
},
},
my_array: {
total: {
type: 'number',
type: 'array',
items: {
total: {
type: 'number',
},
type: { type: 'boolean' },
},
type: { type: 'boolean' },
},
my_str_array: { type: 'keyword' },
my_str_array: { type: 'array', items: { type: 'keyword' } },
},
},
fetch: {
Expand Down Expand Up @@ -91,18 +94,22 @@ export const parsedWorkingCollector: ParsedUsageCollection = [
},
},
my_array: {
total: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
type: {
kind: SyntaxKind.BooleanKeyword,
type: 'BooleanKeyword',
items: {
total: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
type: {
kind: SyntaxKind.BooleanKeyword,
type: 'BooleanKeyword',
},
},
},
my_str_array: {
kind: SyntaxKind.StringKeyword,
type: 'StringKeyword',
items: {
kind: SyntaxKind.StringKeyword,
type: 'StringKeyword',
},
},
},
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions packages/kbn-telemetry-tools/src/tools/manage_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type AllowedSchemaTypes =
| 'date'
| 'float';

export function compatibleSchemaTypes(type: AllowedSchemaTypes) {
export function compatibleSchemaTypes(type: AllowedSchemaTypes | 'array') {
switch (type) {
case 'keyword':
case 'text':
Expand All @@ -40,6 +40,8 @@ export function compatibleSchemaTypes(type: AllowedSchemaTypes) {
case 'float':
case 'long':
return 'number';
case 'array':
return 'array';
default:
throw new Error(`Unknown schema type ${type}`);
}
Expand All @@ -66,10 +68,22 @@ export function isObjectMapping(entity: any) {
return false;
}

function isArrayMapping(entity: any): entity is { type: 'array'; items: object } {
return typeof entity === 'object' && entity.type === 'array' && typeof entity.items === 'object';
}

function getValueMapping(value: any) {
return isObjectMapping(value) ? transformToEsMapping(value) : value;
}

function transformToEsMapping(usageMappingValue: any) {
const fieldMapping: any = { properties: {} };
for (const [key, value] of Object.entries(usageMappingValue)) {
fieldMapping.properties[key] = isObjectMapping(value) ? transformToEsMapping(value) : value;
if (isArrayMapping(value)) {
fieldMapping.properties[key] = { ...value, items: getValueMapping(value.items) };
} else {
fieldMapping.properties[key] = getValueMapping(value);
}
}
return fieldMapping;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-telemetry-tools/src/tools/serializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ describe('getDescriptor', () => {
expect(descriptor).toEqual({
prop1: { kind: TelemetryKinds.MomentDate, type: 'MomentDate' },
prop2: { kind: TelemetryKinds.MomentDate, type: 'MomentDate' },
prop3: { kind: TelemetryKinds.MomentDate, type: 'MomentDate' },
prop4: { kind: TelemetryKinds.Date, type: 'Date' },
prop3: { items: { kind: TelemetryKinds.MomentDate, type: 'MomentDate' } },
prop4: { items: { kind: TelemetryKinds.Date, type: 'Date' } },
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-telemetry-tools/src/tools/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
}

if (ts.isArrayTypeNode(node)) {
return getDescriptor(node.elementType, program);
return { items: getDescriptor(node.elementType, program) };
}

if (ts.isLiteralTypeNode(node)) {
Expand Down
4 changes: 2 additions & 2 deletions src/fixtures/stubbed_logstash_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

import StubIndexPattern from 'test_utils/stub_index_pattern';
import stubbedLogstashFields from 'fixtures/logstash_fields';

import { getKbnFieldType } from '../plugins/data/common';
import { getStubIndexPattern } from '../plugins/data/public/test_utils';
import { uiSettingsServiceMock } from '../core/public/ui_settings/ui_settings_service.mock';

const uiSettingSetupMock = uiSettingsServiceMock.createSetupContract();
Expand All @@ -46,7 +46,7 @@ export default function stubbedLogstashIndexPatternService() {
};
});

const indexPattern = new StubIndexPattern('logstash-*', (cfg) => cfg, 'time', fields, {
const indexPattern = getStubIndexPattern('logstash-*', (cfg) => cfg, 'time', fields, {
uiSettings: uiSettingSetupMock,
});

Expand Down
11 changes: 7 additions & 4 deletions src/fixtures/telemetry_collectors/working_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ export const myCollector = makeUsageCollector<Usage>({
type: { type: 'boolean' },
},
my_array: {
total: {
type: 'number',
type: 'array',
items: {
total: {
type: 'number',
},
type: { type: 'boolean' },
},
type: { type: 'boolean' },
},
my_str_array: { type: 'keyword' },
my_str_array: { type: 'array', items: { type: 'keyword' } },
my_index_signature_prop: {
count: { type: 'number' },
avg: { type: 'number' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ describe('IndexPattern', () => {
await indexPattern.addScriptedField(
scriptedField.name,
scriptedField.script,
scriptedField.type,
'lang'
scriptedField.type
);

const scriptedFields = indexPattern.getScriptedFields();
Expand All @@ -206,7 +205,7 @@ describe('IndexPattern', () => {
const scriptedField = last(scriptedFields) as any;
expect.assertions(1);
try {
await indexPattern.addScriptedField(scriptedField.name, "'new script'", 'string', 'lang');
await indexPattern.addScriptedField(scriptedField.name, "'new script'", 'string');
} catch (e) {
expect(e).toBeInstanceOf(DuplicateField);
}
Expand Down
Loading

0 comments on commit ee7b238

Please sign in to comment.