Skip to content
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

Merged
merged 3 commits into from
Aug 29, 2017

Conversation

Bargs
Copy link
Contributor

@Bargs Bargs commented Aug 25, 2017

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

Copy link
Member

@weltenwort weltenwort left a 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.

@Bargs
Copy link
Contributor Author

Bargs commented Aug 28, 2017

It's a fair point. I considered a separate setting, but I feared setting a precedent for further config inflation. sort:options is already a weird setting though, its behavior isn't at all obvious to an end user. A separate option is probably the lesser of two evils.

@lukasolson
Copy link
Member

I tend to agree with @weltenwort here. I'd rather see a separate config option.

And yeah, the existing sort:options option is pretty strange, and I don't think we should suggest setting the order inside of those options, seeing as how the order can and should change as you change it inside Discover.

Bargs added 2 commits August 28, 2017 16:59
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
@Bargs Bargs force-pushed the defaultSortOrder branch from 45d66ad to 2b7c73e Compare August 28, 2017 21:33
@Bargs
Copy link
Contributor Author

Bargs commented Aug 28, 2017

I don't think we should suggest setting the order inside of those options, seeing as how the order can and should change as you change it inside Discover.

That would still work, the sort:options are only used as a default. I'm remembering now, that's why I felt ok about using sort:options. From a user's perspective they're setting defaults with this option so it's actually surprising Discover doesn't respect it (I was surprised when I tried it). I felt like I was making sort:options more consistent. That was my thought process at least /shurg

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 = {}) {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 faba375

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Bargs
Copy link
Contributor Author

Bargs commented Aug 29, 2017

Tests passed, s3 uploads failed

@Bargs Bargs merged commit 3043ee7 into elastic:master Aug 29, 2017
Bargs added a commit to Bargs/kibana that referenced this pull request Aug 29, 2017
* 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
Bargs added a commit to Bargs/kibana that referenced this pull request Aug 29, 2017
* 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
Bargs added a commit that referenced this pull request Aug 29, 2017
* 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
Bargs added a commit that referenced this pull request Aug 29, 2017
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants