[Discover] Move total count logic from UnifiedHistogram to Discover main #177156
Labels
Feature:Discover
Discover Application
impact:medium
Addressing this issue will have a medium level of impact on the quality/strength of our product.
loe:needs-research
This issue requires some research before it can be worked on or estimated
Team:DataDiscovery
Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.
technical debt
Improvement of the software architecture and operational architecture
Currently, Discover passes filters, query and time range to UnifiedHistogram component and UnifiedHistogram component reports back the total count of documents matching the query.
If chart is visible, UnifiedHistogram fetches chart data and derives total count from that request. In some ES|QL cases, Discover passes
table
with already fetched results andUnifiedHistogram derives total count from that passed data(outdated, Discover takes the number of fetched rows). Then it reports the result back to Discover.If chart is hidden, UnifiedHistogram makes a request to fetch only total count for data view mode. Then it reports the result back to Discover.
Also there are issues with having redundant requests from UnifiedHistogram #165192
The logic is getting complicated and seems like that this back and forth between UnifiedHistogram and Discover can become a problem of reporting an incorrect total hits count in the future. During the development I ran into an issue once (time range was not updated in UnifiedHistogram correctly) when
0
was coming from UnifiedHistogram and it was triggering "No results" screen in Discover although Discover request had results.So it's important to make sure that the same filters, query and time range are used both for Discover request and for total hits count request. We can achieve this by moving the logic of deriving total hits count out of the UnifiedHistogram and closer to the the Discover main request (as a separate
_count
request or withtrack_total_hits
). And we should not use component props for passing filters, query and time range and relying on React hooks.The text was updated successfully, but these errors were encountered: