-
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
Check sort:options for Discover default sort order #13708
Conversation
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.
It is unfortunate that the sort:options
advanced setting is now interpreted in two different places on two different abstraction layers (the discover controller and the courier SearchSource
), but I can not see a unified solution either.
I wonder if a separate discover:sort:defaultOrder
setting might instead be advantageous to prevent increased entanglement of the discover and courier layers.
It's a fair point. I considered a separate setting, but I feared setting a precedent for further config inflation. |
I tend to agree with @weltenwort here. I'd rather see a separate config option. And yeah, the existing |
I went back and forth on a lot of different solutions for this. Initially I thought it would make sense to just allow users to set a default saved search in Discover. There were some problems with that approach though. It would change the default workflow in Discover. Instead of starting with an unsaved search, users would be editing a saved search by default. I could see this leading to a lot of unintentional changes to the default. The settings from the default saved search also wouldn't carry over to new searches, which I think would be desirable most of the time. I also considered adding a new advanced setting for specifying a default sort field/direction. This kind of setting would make more sense at the index pattern level though. One field may not be valid across all index patterns. So I ended up going with the simplest solution. It solves the issue identified by the author of the linked issue and nothing more. If a sort order is specified in the existing sort:options advanced setting, we'll use that direction when sorting on the index pattern's timestamp field by default. Fixes elastic#5164
45d66ad
to
2b7c73e
Compare
That would still work, the Anyway, I still updated it to use a separate setting, take a look at let me know what you think. |
@@ -6,7 +6,7 @@ import _ from 'lodash'; | |||
* @param {object} indexPattern used for determining default sort | |||
* @returns {object} a sort object suitable for returning to elasticsearch | |||
*/ | |||
export function getSort(sort, indexPattern) { | |||
export function getSort(sort, indexPattern, sortOptions = {}) { |
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.
How about just passing defaultOrder
here, since that is the only property in use right now?
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.
👍 faba375
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
Tests passed, s3 uploads failed |
* Check sort:options for Discover default sort order I went back and forth on a lot of different solutions for this. Initially I thought it would make sense to just allow users to set a default saved search in Discover. There were some problems with that approach though. It would change the default workflow in Discover. Instead of starting with an unsaved search, users would be editing a saved search by default. I could see this leading to a lot of unintentional changes to the default. The settings from the default saved search also wouldn't carry over to new searches, which I think would be desirable most of the time. I also considered adding a new advanced setting for specifying a default sort field/direction. This kind of setting would make more sense at the index pattern level though. One field may not be valid across all index patterns. So I ended up going with the simplest solution. It solves the issue identified by the author of the linked issue and nothing more. If a sort order is specified in the existing sort:options advanced setting, we'll use that direction when sorting on the index pattern's timestamp field by default. Fixes elastic#5164 * Create a new advanced setting instead of re-using sort:options * Just pass a default order
* Check sort:options for Discover default sort order I went back and forth on a lot of different solutions for this. Initially I thought it would make sense to just allow users to set a default saved search in Discover. There were some problems with that approach though. It would change the default workflow in Discover. Instead of starting with an unsaved search, users would be editing a saved search by default. I could see this leading to a lot of unintentional changes to the default. The settings from the default saved search also wouldn't carry over to new searches, which I think would be desirable most of the time. I also considered adding a new advanced setting for specifying a default sort field/direction. This kind of setting would make more sense at the index pattern level though. One field may not be valid across all index patterns. So I ended up going with the simplest solution. It solves the issue identified by the author of the linked issue and nothing more. If a sort order is specified in the existing sort:options advanced setting, we'll use that direction when sorting on the index pattern's timestamp field by default. Fixes elastic#5164 * Create a new advanced setting instead of re-using sort:options * Just pass a default order
* Check sort:options for Discover default sort order I went back and forth on a lot of different solutions for this. Initially I thought it would make sense to just allow users to set a default saved search in Discover. There were some problems with that approach though. It would change the default workflow in Discover. Instead of starting with an unsaved search, users would be editing a saved search by default. I could see this leading to a lot of unintentional changes to the default. The settings from the default saved search also wouldn't carry over to new searches, which I think would be desirable most of the time. I also considered adding a new advanced setting for specifying a default sort field/direction. This kind of setting would make more sense at the index pattern level though. One field may not be valid across all index patterns. So I ended up going with the simplest solution. It solves the issue identified by the author of the linked issue and nothing more. If a sort order is specified in the existing sort:options advanced setting, we'll use that direction when sorting on the index pattern's timestamp field by default. Fixes #5164 * Create a new advanced setting instead of re-using sort:options * Just pass a default order
* Check sort:options for Discover default sort order I went back and forth on a lot of different solutions for this. Initially I thought it would make sense to just allow users to set a default saved search in Discover. There were some problems with that approach though. It would change the default workflow in Discover. Instead of starting with an unsaved search, users would be editing a saved search by default. I could see this leading to a lot of unintentional changes to the default. The settings from the default saved search also wouldn't carry over to new searches, which I think would be desirable most of the time. I also considered adding a new advanced setting for specifying a default sort field/direction. This kind of setting would make more sense at the index pattern level though. One field may not be valid across all index patterns. So I ended up going with the simplest solution. It solves the issue identified by the author of the linked issue and nothing more. If a sort order is specified in the existing sort:options advanced setting, we'll use that direction when sorting on the index pattern's timestamp field by default. Fixes #5164 * Create a new advanced setting instead of re-using sort:options * Just pass a default order
I went back and forth on a lot of different solutions for this.
Initially I thought it would make sense to just allow users to set a
default saved search in Discover. There were some problems with that
approach though. It would change the default workflow in Discover.
Instead of starting with an unsaved search, users would be editing a
saved search by default. I could see this leading to a lot of
unintentional changes to the default. The settings from the default
saved search also wouldn't carry over to new searches, which I think
would be desirable most of the time.
I also considered adding a new advanced setting for specifying a default
sort field/direction. This kind of setting would make more sense at the
index pattern level though. One field may not be valid across all index
patterns.
So I ended up going with the simplest solution. It solves the issue
identified by the author of the linked issue and nothing more. If a sort
order is specified in the existing sort:options advanced setting, we'll
use that direction when sorting on the index pattern's timestamp field
by default.
Fixes #5164