-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Maps] add support for Top Hits to Documents source #38052
Conversation
Pinging @elastic/kibana-gis |
@gchaps I need some help with the text on this PR. Do the labels in the side editor under |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cool! Tested in Firefox. I just have a couple of concerns.
- Since this is a terms aggregation would
term
a better word thanentity
in the source settings? - It would be nice to have the more recent top hits draw on top of the older ones. See the screenshots below for example. Notice that the newer hits are drawn underneath older hits which leads me to misinterpret the direction the plane was traveling.
@thomasneirynck suggested using
good feedback. I can sort the list by timestamp. Would you expect items across entities to be sorted so the newest always displays on top (regardless of which entity it comes from)? Or could the sort just be local to each entity? |
💚 Build Succeeded |
💚 Build Succeeded |
x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js
Show resolved
Hide resolved
x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js
Outdated
Show resolved
Hide resolved
x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js
Show resolved
Hide resolved
@@ -253,10 +336,30 @@ export class ESSearchSource extends AbstractESSource { | |||
getSourceTooltipContent(sourceDataRequest) { | |||
const featureCollection = sourceDataRequest ? sourceDataRequest.getData() : null; | |||
const meta = sourceDataRequest ? sourceDataRequest.getMeta() : {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like getMeta()
always minimally returns an empty object so no need for this conditional assignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional is for whether sourceDataRequest exists. Can not call getMeta
on null. This statement is still needed
x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js
Show resolved
Hide resolved
x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js
Show resolved
Hide resolved
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
Tested in Firefox. Newer points are now placed on top of older points.
Lets not couple that suggestion to this PR. I can open an issue for the discussion. We have the same thing when you apply dynamic styling but do not select the field yet |
return { | ||
hits: resp.hits.hits, | ||
meta: { | ||
areResultsTrimmed: resp.hits.total > resp.hits.hits.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case _runEsQuery
throws, we might want to use _.get(resp, ....)
with defaults for the values here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If _runEsQuery throws then it won't matter because our function will throw since _runEsQuery is not wrapped in a try/catch. This is the expected behavior so vector_layer can catch the exception and call onLoadError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Great feature, nice work!
code review. tested in chrome
* top hits * fetch top hits * trigger load if top hits configuration changes * text clean-up * add functional tests for top hits * add functional test verify configuration updates re-fetch data * show entity source tooltip message for top hits * include entities cound in results trimmed message * pass fields needed for data driven styling and joins * fix i18n problem * more i18n changes * reverse hits list so most recent events are drawn on top * review feedback * set meta to null when no sourceDataRequest
* top hits * fetch top hits * trigger load if top hits configuration changes * text clean-up * add functional tests for top hits * add functional test verify configuration updates re-fetch data * show entity source tooltip message for top hits * include entities cound in results trimmed message * pass fields needed for data driven styling and joins * fix i18n problem * more i18n changes * reverse hits list so most recent events are drawn on top * review feedback * set meta to null when no sourceDataRequest
Replaces #33320
fixes #30738
This PR updates the Documents source to allows users to use Top hits aggregation to view the most recent documents per entity. Unlike a normal search, which just returns the first 2000 results, top hits performs a terms aggregation and then gathers documents per term. This ensures that each entity will display results and can be used for use cases like "show me the last known location for each entity".