[ML] Do not pass datafeed query to Discover in custom URL (#26957)

This commit is contained in:
Pete Harverson 2018-12-11 15:30:41 +00:00 committed by GitHub
parent eb04a36054
commit 4e63fbdeb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View file

@ -113,13 +113,13 @@ export function isValidCustomUrlSettings(settings, savedCustomUrls) {
return isValid;
}
export function buildCustomUrlFromSettings(settings, job) {
export function buildCustomUrlFromSettings(settings) {
// Dashboard URL returns a Promise as a query is made to obtain the full dashboard config.
// So wrap the other two return types in a Promise for consistent return type.
if (settings.type === URL_TYPE.KIBANA_DASHBOARD) {
return buildDashboardUrlFromSettings(settings);
} else if (settings.type === URL_TYPE.KIBANA_DISCOVER) {
return Promise.resolve(buildDiscoverUrlFromSettings(settings, job));
return Promise.resolve(buildDiscoverUrlFromSettings(settings));
} else {
const urlToAdd = {
url_name: settings.label,
@ -219,7 +219,7 @@ function buildDashboardUrlFromSettings(settings) {
}
function buildDiscoverUrlFromSettings(settings, job) {
function buildDiscoverUrlFromSettings(settings) {
const { discoverIndexPatternId, queryFieldNames } = settings.kibanaSettings;
// Add time settings to the global state URL parameter with $earliest$ and
@ -238,10 +238,10 @@ function buildDiscoverUrlFromSettings(settings, job) {
index: discoverIndexPatternId
};
// Use the query from the datafeed only if no job entities are selected.
let query = job.datafeed_config.query;
// If partitioning field entities have been configured add tokens
// to the URL to use in the Discover page search.
// To put entities in filters section would involve creating parameters of the form
// Ideally we would put entities in the filters section, but currently this involves creating parameters of the form
// filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:b30fd340-efb4-11e7-a600-0f58b1422b87,
// key:airline,negate:!f,params:(query:AAL,type:phrase),type:phrase,value:AAL),query:(match:(airline:(query:AAL,type:phrase)))))
// which includes the ID of the index holding the field used in the filter.
@ -257,16 +257,12 @@ function buildDiscoverUrlFromSettings(settings, job) {
queryString += `${escapeForElasticsearchQuery(fieldName)}:"$${fieldName}$"`;
});
query = {
appState.query = {
language: 'lucene',
query: queryString
};
}
if (query !== undefined) {
appState.query = query;
}
const _a = rison.encode(appState);
const urlValue = `kibana#/discover?_g=${_g}&_a=${_a}`;

View file

@ -113,7 +113,7 @@ class CustomUrlsUI extends Component {
}
addNewCustomUrl = () => {
buildCustomUrlFromSettings(this.state.editorSettings, this.props.job)
buildCustomUrlFromSettings(this.state.editorSettings)
.then((customUrl) => {
const customUrls = [...this.state.customUrls, customUrl];
this.setCustomUrls(customUrls);
@ -131,7 +131,7 @@ class CustomUrlsUI extends Component {
onTestButtonClick = () => {
const job = this.props.job;
const { intl } = this.props;
buildCustomUrlFromSettings(this.state.editorSettings, job)
buildCustomUrlFromSettings(this.state.editorSettings)
.then((customUrl) => {
getTestUrl(job, customUrl)
.then((testUrl) => {