Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down