-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Discover] Experimental usage of ES fields API #75407
Changes from all commits
4662f35
379fd8c
008bdc1
0c7bf3a
4650db8
2d4b73a
3d5e8b7
d19e7ee
17d9bce
f84b36d
32c0184
9ed5a95
9c5160f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,7 +256,7 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise | |
$scope.state = { ...newState }; | ||
|
||
// detect changes that should trigger fetching of new data | ||
const changes = ['interval', 'sort'].filter( | ||
const changes = ['interval', 'sort', 'columns'].filter( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to resubmit the query to display subfields like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a bit concerned around performance of that part. Right now we're not doing additional queries (to fetch data) if we modify the columns. Especially given that the Discover query is atm very unoptimized (e.g. contains the aggregation for the chart in each fetch for the data), and thus can potentially also be rather slow-ish, doing this now for every column add/remove/reorder feels like a significant performance regression (e.g. on our issue instance, which is not having a significant large dataset, every discover request takes ~2s). Especially when a user starts building a discover view, she'll need to first add a couple of columns, which will then all trigger another request and we could slow down the creation time and UX significantly with this change. We could optimize this code to e.g. exclude column reorders, but I have the feeling we're still in a problematic situation afterwards. I currently don't see how we could check if a change to column would require us to refetch, since we're not knowing which of the column fields could be runtime fields and thus require a refetch here. I am happy for any suggestions here. cc @stacey-gammon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, this is the disadvantage of this solution, but we since we currently don't know which fields are runtime, we would currently need to fetch all fields + _source as an alternative.
Wouldn't each new fetch abort the old one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we need to evaluate and try to quantify the fallout of this change a bit better. We should not make this kind of larger performance impacts in the most uses application in Kibana willy-nilly and hopef or the best.
That would miticate the problem a bit, but without the quantification I have the feeling we still run into problems, since if we assume a 2 second request, this could correlate very roughly to the interaction time the user needs to get to the next field they want to add, so they actually never run into the situation where the previous request would be cancelled, but into a situation where the UI every time they want to add the next column is frozen for some time, because we're parsing some large JSON response and redrawing the page. |
||
(prop) => !_.isEqual(newStatePartial[prop], oldStatePartial[prop]) | ||
); | ||
|
||
|
@@ -948,8 +948,14 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise | |
|
||
$scope.updateDataSource = () => { | ||
const { indexPattern, searchSource } = $scope; | ||
const { docvalueFields } = indexPattern.getComputedFields(); | ||
const columns = $scope.state.columns.filter( | ||
(name) => !docvalueFields.find((docVal) => docVal.field === name) | ||
); | ||
searchSource | ||
.setField('index', $scope.indexPattern) | ||
.setField('fieldsApi', columns) | ||
.setField('source', true) | ||
.setField('size', $scope.opts.sampleSize) | ||
.setField( | ||
'sort', | ||
|
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.
I think we need to start this as a larger discussion with App Arch and Stacey (feel free to ping them here once you want to open this PR for review). I am a bit torn on already having a
fields
API in the search source and now add afieldsApi
parameter to it, that will set this to thefields
part of the query. I think the following code as a consumer is just not really understandable:Since
SearchSource
is a rather present API, we're needing in a lot of places, I'd not want to dilute it for a work-around that we need in Discover.The
fields
field in search source, already does multiple things, likestored_fields
anddocvalue_fields
. I think we should rather make sure that key will also handlefields
(in the ES query) correctly. Maybe we can even replacestored_fields
anddocvalue_fields
in that API completely by using thefields
API for them too.tl;dr: I think we need to have some discussion with App Arch to find a proper longer term solution for this part, the other part looks as the initial workaround fine for me.
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.
dear @elastic/kibana-app-arch & @stacey-gammon
so the requirements are, that
SearchSource
would would provide access to thesearch-fields
APIhttps://www.elastic.co/guide/en/elasticsearch/reference/master/search-fields.html
Like Tim mentioned the
fields
field was already taken, modifying it's functionality broke several functional tests, so I've added afieldsApi
field, which would provide the functionalityDiscover
would need. Maybe it would make sense to create a separate issue for this, unless everybody thinks the solution provided in this PR is fine. I also would prefer a singlefields
field in SearchSource, but the approach I've tried to implement here broke the following functional tests:https://kibana-ci.elastic.co/job/elastic+kibana+pipeline-pull-request/73366/
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.
++ to creating a separate issue to solve this. I think we should make sure the changes made to search source are developer friendly, documented, tested, etc, and not exposed as a hack to solve this particular problem in the short term.
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.
Here's the issue: #77241
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.
thanks @kertal, we'll discuss this and get back to you. is this a blocker for discover at the moment ?
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.
hmm, that issue seems very general, should we open one for discover specifically ? what exactly is the issue for discover, the request searchsource sends out or the response provided ? searchsource will return full response so its up to you how you parse it.
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.
@ppisljar I've created an issue #77300 but closed in favor of #77241. It's basically the question: how to extend
SearchSource
in a non-hacky way to have access to the fields API of search. Without the extension runtime fields don't work in Discover.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.
#77107 is the Discover specific issue that this PR attempts to fix.