Skip to content

Commit

Permalink
Merge branch 'master' into so-management/remove_legacy_import_support
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Sep 2, 2021
2 parents 912c588 + e6faa58 commit ab16382
Show file tree
Hide file tree
Showing 323 changed files with 4,313 additions and 2,925 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1656,5 +1656,24 @@ module.exports = {
'@typescript-eslint/prefer-ts-expect-error': 'error',
},
},

/**
* Disallow `export *` syntax in plugin/core public/server/common index files and instead
* require that plugins/core explicitly export the APIs that should be accessible outside the plugin.
*
* To add your plugin to this list just update the relevant glob with the name of your plugin
*/
{
files: [
'src/core/{server,public,common}/index.ts',
'src/plugins/*/{server,public,common}/index.ts',
'src/plugins/*/*/{server,public,common}/index.ts',
'x-pack/plugins/*/{server,public,common}/index.ts',
'x-pack/plugins/*/*/{server,public,common}/index.ts',
],
rules: {
'@kbn/eslint/no_export_all': 'error',
},
},
],
};
Binary file modified docs/discover/images/add-field-to-pattern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/discover/images/customer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/discover/images/discover-from-visualize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/discover/images/discover-search-for-relevance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/discover/images/document-table-expanded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/discover/images/document-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/discover/images/double-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/discover/images/downward-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/discover/images/hello-field.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 6 additions & 9 deletions docs/discover/search-for-relevance.asciidoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[[discover-search-for-relevance]]
== Search for relevance
Sometimes you might be unsure which documents best match your search.
{es} assigns a relevancy, or score to each document, so you can
can narrow your search to the documents with the most relevant results.
The higher the score, the better it matches your query.
Expand All @@ -12,25 +11,23 @@ the <<gs-get-data-into-kibana, sample flights data set>>, or you can use your ow
. In *Discover*, open the index pattern dropdown, and select that data you want to work with.
+
For the sample flights data, set the index pattern to *kibana_sample_data_flights*.
. In the query bar, click *KQL*, and then turn it off.
+
You're now using the <<lucene-query, Lucene query syntax>>.

. Run your search. For the sample data, try:
+
```ts
Warsaw OR Venice OR Clear
```
. If you don't see any results, expand the <<set-time-filter,time range>>, for example to *Last 7 days*.
. From the list of *Available fields*, add `_score` and any other fields you want to the document table.
. To sort the `_score` column in descending order, hover over its header, and then click twice on
the arrow icon
image:images/double-arrow.png[Double arrow icon to indicate sorting] so it changes to
. To sort the `_score` column in descending order, hover over its header, and set
the sort icon to
image:images/downward-arrow.png[Downward pointing arrow to indicate descending sorting].
+
At this point, you're doing a multi-column sort: first by `Time`, and then by `_score`.
. To turn off sorting for the `Time` field, hover over its header, and then click the down arrow.
. To turn off sorting for the `Time` field, hover over its header, and set the sort icon to
image:images/double-arrow.png[Arrow on both ends of the icon indicates sorting is off].
+
Your table now sorts documents from most to least relevant.
+
[role="screenshot"]
image::images/discover-search-for-relevance.png["Example of a search for relevance"]
image::images/discover-search-for-relevance.png["Documents are sorted from most relevant to least relevant."]
8 changes: 3 additions & 5 deletions docs/user/discover.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ If you are using the sample data, this value was set when you added the data.
If you are using your own data, and it does not have a time field, the range selection is not available.

. To view the count of documents for a given time in the specified range,
click and drag the mouse over the histogram.
click and drag the mouse over the chart.

[float]
[[explore-fields-in-your-data]]
Expand Down Expand Up @@ -108,7 +108,7 @@ them to your document table. Your table should look similar to this:
image:images/document-table.png[Document table with fields for manufacturer, customer_first_name, and customer_last_name]

. To rearrange the table columns, hover the mouse over a
column header, and then use the move controls.
column header, and then use the move control.

. To view more of the document table, click *Hide chart*.

Expand Down Expand Up @@ -275,7 +275,7 @@ image:images/discover-maps.png[Map containing documents]
[[share-your-findings]]
=== Share your findings

To share your findings with a larger audience, click *Share* in the toolbar. For detailed information about the sharing options, refer to <<reporting-getting-started,Reporting>>.
To share your findings with a larger audience, click *Share* in the *Discover* toolbar. For detailed information about the sharing options, refer to <<reporting-getting-started,Reporting>>.


[float]
Expand All @@ -285,8 +285,6 @@ To share your findings with a larger audience, click *Share* in the toolbar. For

* <<discover-search-for-relevance, Search for relevance>>.

* <<reporting-getting-started, Present your findings in a report>>.

* <<kibana-discover-settings, Configure Discover>> to better meet your needs.
Go to **Advanced Settings** to configure the number of documents to show,
the table columns that display by default, and more.
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-eslint-plugin-eslint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PKG_REQUIRE_NAME = "@kbn/eslint-plugin-eslint"
SOURCE_FILES = glob(
[
"rules/**/*.js",
"helpers/**/*.js",
"index.js",
"lib.js",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
* Side Public License, v 1.
*/

import './action_bar_directive';
/* eslint-disable no-restricted-syntax */

export class Bar {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
* Side Public License, v 1.
*/

export { handleSourceColumnState } from './state_helpers';
export { PromiseServiceCreator } from './promises';
/* eslint-disable no-restricted-syntax */

export const one = 1;
export const two = 2;
export const three = 3;
31 changes: 31 additions & 0 deletions packages/kbn-eslint-plugin-eslint/__fixtures__/foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.
*/

/* eslint-disable no-restricted-syntax */

export type { Bar as ReexportedClass } from './bar';

export const someConst = 'bar';

// eslint-disable-next-line prefer-const
export let someLet = 'bar';

export function someFunction() {}

export class SomeClass {}

export interface SomeInterface {
prop: number;
}

export enum SomeEnum {
a = 'a',
b = 'b',
}

export type TypeAlias = string[];
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Side Public License, v 1.
*/

// required for i18nIdDirective
import 'angular-sanitize';
/* eslint-disable no-restricted-syntax */

import './doc';
import './context';
export * from './foo';
82 changes: 82 additions & 0 deletions packages/kbn-eslint-plugin-eslint/helpers/codegen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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.
*/

const t = require('@babel/types');
const { default: generate } = require('@babel/generator');

/** @typedef {import('./export_set').ExportSet} ExportSet */

/**
* Generate code for replacing a `export * from './path'`, ie.
*
* export type { foo } from './path'
* export { bar } from './path'
* @param {ExportSet} exportSet
* @param {string} source
*/
const getExportCode = (exportSet, source) => {
const exportedTypes = exportSet.types.size
? t.exportNamedDeclaration(
undefined,
Array.from(exportSet.types).map((n) => t.exportSpecifier(t.identifier(n), t.identifier(n))),
t.stringLiteral(source)
)
: undefined;

if (exportedTypes) {
exportedTypes.exportKind = 'type';
}

const exportedValues = exportSet.values.size
? t.exportNamedDeclaration(
undefined,
Array.from(exportSet.values).map((n) =>
t.exportSpecifier(t.identifier(n), t.identifier(n))
),
t.stringLiteral(source)
)
: undefined;

return generate(t.program([exportedTypes, exportedValues].filter(Boolean))).code;
};

/**
* Generate code for replacing a `export * as name from './path'`, ie.
*
* import { foo, bar } from './path'
* export const name = { foo, bar }
*
* @param {string} nsName
* @param {string[]} exportNames
* @param {string} source
*/
const getExportNamedNamespaceCode = (nsName, exportNames, source) => {
return generate(
t.program([
t.importDeclaration(
exportNames.map((n) => t.importSpecifier(t.identifier(n), t.identifier(n))),
t.stringLiteral(source)
),
t.exportNamedDeclaration(
t.variableDeclaration('const', [
t.variableDeclarator(
t.identifier(nsName),
t.objectExpression(
exportNames.map((n) =>
t.objectProperty(t.identifier(n), t.identifier(n), false, true)
)
)
),
])
),
])
).code;
};

module.exports = { getExportCode, getExportNamedNamespaceCode };
34 changes: 34 additions & 0 deletions packages/kbn-eslint-plugin-eslint/helpers/export_set.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.
*/

/**
* Helper class to collect exports of different types, either "value" exports or "type" exports
*/
class ExportSet {
constructor() {
/** @type {Set<string>} */
this.values = new Set();

/** @type {Set<string>} */
this.types = new Set();
}

get size() {
return this.values.size + this.types.size;
}

/**
* @param {'value'|'type'} type
* @param {string} value
*/
add(type, value) {
this[type + 's'].add(value);
}
}

module.exports = { ExportSet };
Loading

0 comments on commit ab16382

Please sign in to comment.