Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into chore/console…
Browse files Browse the repository at this point in the history
…-to-np-ready

* 'master' of github.com:elastic/kibana: (25 commits)
  [ML] Fixes display of matching modules in index data visualizer (elastic#45261)
  [Console] Update indentation behaviour (elastic#45249)
  Convert value provided to PhraseValueInput to string to catch Exception (elastic#45259)
  [Region Map] Fix loading default vector map and base layer setting (elastic#43858)
  [ML] Fixing empty time range when cloning jobs (elastic#45286)
  [ML] Fixing wizard validation delay (elastic#45265)
  [Logs UI] Interpret finished analysis jobs as healthy (elastic#45268)
  [Console] SQL template with triple quote in completion (elastic#45248)
  [ML] Data Frames: Cards as links (elastic#45254)
  fix(code/frontend): should show updating instead of cloning when updating (elastic#45238)
  fix(code/frontend): fix document search result from (elastic#45236)
  disable another flaky suite (elastic#45323) (elastic#45330)
  disable flaky suite (elastic#45105)
  skip flaky suite (elastic#43069)
  skip flaky suite (elastic#45089)
  disable jest suite that has no enabled tests (elastic#44250)
  disable flaky test (elastic#45317)
  disable flaky test (elastic#45315)
  [DOCS] Creates developer folder (elastic#45280)
  [SIEM] Changes ML conditional links to use tabs, fixes a small bug with null filterQuery   (elastic#45218)
  ...
  • Loading branch information
jloleysens committed Sep 11, 2019
2 parents e351ba2 + c1f1e15 commit c82003c
Show file tree
Hide file tree
Showing 142 changed files with 1,598 additions and 896 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 0 additions & 25 deletions docs/development.asciidoc

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ include::migration.asciidoc[]

include::CHANGELOG.asciidoc[]

include::development/index.asciidoc[]
include::developer/index.asciidoc[]

include::redirects.asciidoc[]
Binary file added docs/maps/images/create_phrase_filter.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 added docs/maps/images/create_spatial_filter.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 added docs/maps/images/filter_icon.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/maps/images/global_search_bar.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/maps/images/global_search_multiple_indices_query1.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/maps/images/global_search_multiple_indices_query2.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 added docs/maps/images/tools_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 53 additions & 2 deletions docs/maps/search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
[[maps-search]]
== Searching your data

**Elastic Maps** embeds the query bar for real-time ad hoc search.
**Elastic Maps** embeds the search bar for real-time search.
Only layers requesting data from {es} are filtered when you submit a search request.
Layers narrowed by the search context contain the filter icon image:maps/images/filter_icon.png[] to the right of layer name in the legend.

You can create a layer that requests data from {es} from the following:

Expand All @@ -13,13 +14,51 @@ You can create a layer that requests data from {es} from the following:

** Grid aggregation source

** <<terms-join>>
** <<terms-join>>. The search context is applied to both the terms join and the vector source when the vector source is provided by Elasticsearch documents.

* <<heatmap-layer>> with Grid aggregation source

[role="screenshot"]
image::maps/images/global_search_bar.png[]

[role="xpack"]
[[maps-create-filter-from-map]]
=== Creating filters from your map

You can create two types of filters by interacting with your map:

* <<maps-spatial-filters, Spatial filters>>
* <<maps-phrase-filter, Phrase filters>>

[float]
[[maps-spatial-filters]]
==== Spatial filters

A spatial filter narrow searchs results to documents that either intersect with, are within, or do not intersect with the specified geometry.

You can create spatial filters in two ways:

* Click the tool icon image:maps/images/tools_icon.png[], and then draw a polygon or bounding box on the map to define the spatial filter.
* Click *Filter by geometry* in a tooltip, and then use the feature's geometry for the spatial filter.
+
[role="screenshot"]
image::maps/images/create_spatial_filter.png[]

Spatial filters have the following properties:

* *Geometry label* enables you to provide a meaningful name for your spatial filter.
* *Spatial field* specifies the geo_point or geo_shape field used to determine if a document matches the spatial relation with the specified geometry.
* *Spatial relation* determines the {ref}/query-dsl-geo-shape-query.html#_spatial_relations[spatial relation operator] to use at search time. Only available when *Spatial field* is set to geo_shape.

[float]
[[maps-phrase-filter]]
==== Phrase filters

A phrase filter narrows search results to documents that contain the specified text.
You can create a phrase filter by clicking the plus icon image:maps/images/gs_plus_icon.png[] in a feature tooltip.

[role="screenshot"]
image::maps/images/create_phrase_filter.png[]

[role="xpack"]
[[maps-layer-based-filtering]]
Expand All @@ -43,6 +82,18 @@ This can also occur with a single layer with an {es} source and a <<terms-join>>

Searching across multiple indices might sometimes result in empty layers.
The most common cause for empty layers are searches for a field that exists in one index, but does not exist in other indices.

[float]
[[maps-disable-search-for-layer]]
==== Disable search for layer

To prevent the global search bar from applying search context to a layer, clear the *Apply global filter to layer* checkbox in Layer settings.
Disabling the search context applies to the layer source and all <<terms-join, term joins>> configured for the layer.

[float]
[[maps-add-index-search]]
==== Use _index in your search

Add {ref}/mapping-index-field.html[_index] to your search to include documents from indices that do not contain a search field.

For example, suppose you have a vector layer showing the `kibana_sample_data_logs` documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,14 @@ export default function (editor) {
let valueToInsert = termAsString;
let templateInserted = false;
if (context.addTemplate && !_.isUndefined(term.template) && !_.isNull(term.template)) {
const indentedTemplateLines = utils.jsonToString(term.template, true).split('\n');
let indentedTemplateLines;
// In order to allow triple quoted strings in template completion we check the `__raw_`
// attribute to determine whether this template should go through JSON formatting.
if (term.template.__raw && term.template.value) {
indentedTemplateLines = term.template.value.split('\n');
} else {
indentedTemplateLines = utils.jsonToString(term.template, true).split('\n');
}
let currentIndentation = session.getLine(context.rangeToReplace.start.row);
currentIndentation = currentIndentation.match(/^\s*/)[0];
for (let i = 1; i < indentedTemplateLines.length; i++) // skip first line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ class ScopeResolver extends SharedComponent {
}
function getTemplate(description) {
if (description.__template) {
if (description.__raw && _.isString(description.__template)) {
return {
// This is a special secret attribute that gets passed through to indicate that
// the raw value should be passed through to the console without JSON.stringifying it
// first.
//
// Primary use case is to allow __templates to contain extended JSON special values like
// triple quotes.
__raw: true,
value: description.__template,
};
}
return description.__template;
} else if (description.__one_of) {
return getTemplate(description.__one_of[0]);
Expand Down
39 changes: 30 additions & 9 deletions src/legacy/core_plugins/console/public/quarantined/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,39 @@ utils.reformatData = function (data, indent) {
};

utils.collapseLiteralStrings = function (data) {
return data.replace(/"""(?:\s*\r?\n)?((?:.|\r?\n)*?)(?:\r?\n\s*)?"""/g, function (match, literal) {
return JSON.stringify(literal);
});
const splitData = data.split(`"""`);
for (let idx = 1; idx < splitData.length - 1; idx += 2) {
splitData[idx] = JSON.stringify(splitData[idx]);
}
return splitData.join('');
};

/*
The following regex describes global match on:
1. one colon followed by any number of space characters
2. one double quote (not escaped, special case for JSON in JSON).
3. greedily match any non double quote and non newline char OR any escaped double quote char (non-capturing).
4. handle a special case where an escaped slash may be the last character
5. one double quote
For instance: `: "some characters \" here"`
Will match and be expanded to: `"""some characters " here"""`
*/

const LITERAL_STRING_CANDIDATES = /((:[\s\r\n]*)([^\\])"(\\"|[^"\n])*\\?")/g;

utils.expandLiteralStrings = function (data) {
return data.replace(/("(?:\\"|[^"])*?")/g, function (match, string) {
// expand things with two slashes or more
if (string.split(/\\./).length > 2) {
string = JSON.parse(string).replace('^\s*\n', '').replace('\n\s*^', '');
const append = string.includes('\n') ? '\n' : ''; // only go multi line if the string has multiline
return '"""' + append + string + append + '"""';
return data.replace(LITERAL_STRING_CANDIDATES, function (match, string) {
// Expand to triple quotes if there are _any_ slashes
if (string.match(/\\./)) {
const firstDoubleQuoteIdx = string.indexOf('"');
const colonAndAnySpacing = string.slice(0, firstDoubleQuoteIdx);
const rawStringifiedValue = string.slice(firstDoubleQuoteIdx, string.length);
const jsonValue = JSON.parse(rawStringifiedValue)
.replace('^\s*\n', '')
.replace('\n\s*^', '');
return `${colonAndAnySpacing}"""${jsonValue}"""`;
} else {
return string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ to you """
==========
String only 2
-------------------------------------
"""
"""
starting with new lines and ending as well
"""
"""
-------------------------------------
"starting with new lines and ending as well"
"\nstarting with new lines and ending as well\n"
==========
Strings in requests
-------------------------------------
Expand All @@ -27,8 +27,8 @@ test2
}
-------------------------------------
{
"f": { "somefield" : "test\ntest2" },
"f": { "somefield" : "\ntest\ntest2\n" },
"g": { "script" : "second + \"\\\";" },
"h": 1,
"script": "a + 2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,41 @@
Scripts in requests
-------------------------------------
{
"f": { "script" : { "source": "test\ntest\\2" } },
"g": { "script" : "second + \"\\\";" },
"f": "short with \\",
"h": 1,
"f": { "script": { "source": "\ntest\ntest\\\\\\\\\\\\\\\\2\n" } },
"g": { "script": "second + \"\\\";" },
"a": "short with \\",
"\\\\h": 1,
"script": "a + 2"
}
-------------------------------------
{
"f": { "script" : { "source": """
"f": { "script": { "source": """
test
test\2
test\\\\\\\\2
""" } },
"g": { "script" : """second + "\";""" },
"f": "short with \\",
"h": 1,
"g": { "script": """second + "\";""" },
"a": """short with \""",
"\\\\h": 1,
"script": "a + 2"
}
==========
Preserve triple quotes
-------------------------------------
{
"content\\\": "tri\"ple",
}
-------------------------------------
{
"content\\\": """tri"ple""",
}
==========
Correctly parse with JSON embedded inside values
-------------------------------------
{
"content\\\\": " { \"json\": \"inside\\\\\" ok! 1\n \" } "
}
-------------------------------------
{
"content\\\\": """ { "json": "inside\\" ok! 1
" } """
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class PhraseValueInputUI extends PhraseSuggestor<Props> {
private renderWithSuggestions() {
const { suggestions } = this.state;
const { value, intl, onChange } = this.props;
const options = value ? uniq([value, ...suggestions]) : suggestions;
// there are cases when the value is a number, this would cause an exception
const valueAsStr = String(value);
const options = value ? uniq([valueAsStr, ...suggestions]) : suggestions;
return (
<StringComboBox
placeholder={intl.formatMessage({
Expand All @@ -69,7 +71,7 @@ class PhraseValueInputUI extends PhraseSuggestor<Props> {
})}
options={options}
getLabel={option => option}
selectedOptions={value ? [value] : []}
selectedOptions={value ? [valueAsStr] : []}
onChange={([newValue = '']) => onChange(newValue)}
onSearchChange={this.onSearchChange}
singleSelection={{ asPlainText: true }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
import { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
import { getFilterGenerator } from 'ui/filter_manager';
import { SavedObjectsClientProvider } from 'ui/saved_objects';
import { VisualizeLoaderProvider } from 'ui/visualize/loader/visualize_loader';
import { recentlyAccessed } from 'ui/persisted_log';
import { getDocLink } from 'ui/documentation_links';
import '../components/fetch_error';
Expand Down Expand Up @@ -196,8 +195,6 @@ function discoverController(
localStorage,
uiCapabilities
) {
const visualizeLoader = Private(VisualizeLoaderProvider);
let visualizeHandler;
const Vis = Private(VisProvider);
const responseHandler = vislibSeriesResponseHandlerProvider().handler;
const getUnhashableStates = Private(getUnhashableStatesProvider);
Expand All @@ -214,6 +211,13 @@ function discoverController(

timefilter.disableTimeRangeSelector();
timefilter.disableAutoRefreshSelector();
$scope.timefilterUpdateHandler = (ranges) => {
timefilter.setTime({
from: moment(ranges.from).toISOString(),
to: moment(ranges.to).toISOString(),
mode: 'absolute',
});
};

$scope.getDocLink = getDocLink;
$scope.intervalOptions = intervalOptions;
Expand Down Expand Up @@ -794,15 +798,7 @@ function discoverController(
.resolve(buildVislibDimensions($scope.vis, { timeRange: $scope.timeRange, searchSource: $scope.searchSource }))
.then(resp => responseHandler(tabifiedData, resp))
.then(resp => {
visualizeHandler.render({
as: 'visualization',
value: {
visType: $scope.vis.type.name,
visData: resp,
visConfig: $scope.vis.params,
params: {},
}
});
$scope.histogramData = resp;
});
}

Expand Down Expand Up @@ -1048,13 +1044,6 @@ function discoverController(
$scope.searchSource.setField('aggs', function () {
return $scope.vis.getAggConfig().toDsl();
});

$timeout(async () => {
const visEl = $element.find('#discoverHistogram')[0];
visualizeHandler = await visualizeLoader.embedVisualizationWithSavedObject(visEl, visSavedObject, {
autoFetch: false,
});
});
}

function resolveIndexPatternLoading() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.dscHistogram__header--partial {
font-weight: $euiFontWeightRegular;
min-width: $euiSize * 12;
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'no_results';
@import 'histogram';
Loading

0 comments on commit c82003c

Please sign in to comment.