-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Maps] get max_result_window and max_inner_result_window from index s…
…ettings (#53500) * [Maps] pull ES_SIZE_LIMIT and top hits limit from index settings * get fetch working * get min values from indicies response * use indexSettings.maxResultWindow in documents request size * use max_inner_result_window to define top hits max * update jest test * update docs * more docs changes for top hits * fix line spacing * Update docs/maps/maps-aggregations.asciidoc Co-Authored-By: gchaps <[email protected]> * Update docs/maps/vector-layer.asciidoc Co-Authored-By: gchaps <[email protected]> * add api integration test for indexSettings route * eslint fixes * review feedback * display toast on first index settings fetch failure * clean up Co-authored-by: gchaps <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
cfec717
commit c5e9455
Showing
16 changed files
with
298 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/load_index_settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
DEFAULT_MAX_RESULT_WINDOW, | ||
DEFAULT_MAX_INNER_RESULT_WINDOW, | ||
INDEX_SETTINGS_API_PATH, | ||
} from '../../../../common/constants'; | ||
import { kfetch } from 'ui/kfetch'; | ||
import { toastNotifications } from 'ui/notify'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
let toastDisplayed = false; | ||
const indexSettings = new Map(); | ||
|
||
export async function loadIndexSettings(indexPatternTitle) { | ||
if (indexSettings.has(indexPatternTitle)) { | ||
return indexSettings.get(indexPatternTitle); | ||
} | ||
|
||
const fetchPromise = fetchIndexSettings(indexPatternTitle); | ||
indexSettings.set(indexPatternTitle, fetchPromise); | ||
return fetchPromise; | ||
} | ||
|
||
async function fetchIndexSettings(indexPatternTitle) { | ||
try { | ||
const indexSettings = await kfetch({ | ||
pathname: `../${INDEX_SETTINGS_API_PATH}`, | ||
query: { | ||
indexPatternTitle, | ||
}, | ||
}); | ||
return indexSettings; | ||
} catch (err) { | ||
const warningMsg = i18n.translate('xpack.maps.indexSettings.fetchErrorMsg', { | ||
defaultMessage: `Unable to fetch index settings for index pattern '{indexPatternTitle}'. | ||
Ensure you have '{viewIndexMetaRole}' role.`, | ||
values: { | ||
indexPatternTitle, | ||
viewIndexMetaRole: 'view_index_metadata', | ||
}, | ||
}); | ||
if (!toastDisplayed) { | ||
// Only show toast for first failure to avoid flooding user with warnings | ||
toastDisplayed = true; | ||
toastNotifications.addWarning(warningMsg); | ||
} | ||
console.warn(warningMsg); | ||
return { | ||
maxResultWindow: DEFAULT_MAX_RESULT_WINDOW, | ||
maxInnerResultWindow: DEFAULT_MAX_INNER_RESULT_WINDOW, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import _ from 'lodash'; | ||
import { DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_INNER_RESULT_WINDOW } from '../../common/constants'; | ||
|
||
export function getIndexPatternSettings(indicesSettingsResp) { | ||
let maxResultWindow = Infinity; | ||
let maxInnerResultWindow = Infinity; | ||
Object.values(indicesSettingsResp).forEach(indexSettings => { | ||
const indexMaxResultWindow = _.get( | ||
indexSettings, | ||
'settings.index.max_result_window', | ||
DEFAULT_MAX_RESULT_WINDOW | ||
); | ||
maxResultWindow = Math.min(maxResultWindow, indexMaxResultWindow); | ||
|
||
const indexMaxInnerResultWindow = _.get( | ||
indexSettings, | ||
'settings.index.max_inner_result_window', | ||
DEFAULT_MAX_INNER_RESULT_WINDOW | ||
); | ||
maxInnerResultWindow = Math.min(indexMaxInnerResultWindow, indexMaxResultWindow); | ||
}); | ||
|
||
return { maxResultWindow, maxInnerResultWindow }; | ||
} |
Oops, something went wrong.