-
Notifications
You must be signed in to change notification settings - Fork 77
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
Better ranked search results in app list #561
Conversation
@@ -186,7 +198,11 @@ var AppListComponent = React.createClass({ | |||
|
|||
if (filterText != null && filterText !== "") { | |||
nodesSequence = nodesSequence | |||
.filter(app => app.id.indexOf(filterText) !== -1); | |||
.filter(app => { | |||
app.filterScore = score(app.id, filterText); |
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.
You are modifying the app
here, this should be done only in the store (with emiting an event afterwards).
Also this is done in a filter
. It's not expectable that a filter modifies data.
So this isn't the right approach. Sorry. :)
Let's try to sort and score the list where the sorting belongs to.
Could you add a sort function after the .sort()-function at line 316?
if (filterText != null) {
nodesSequences.sort((a, b) => {
return score(a.id, filterText) > score(b.id, filterText)
? -1
: 1;
});
}
Didn't tested it, but it should go into this direction.
Maybe there is also a more efficient way by integrating this into the already existing sort-function. Not sure.
This doesn't modify the app itself. :)
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.
You're totally right. Will follow your suggestions.
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.
:)
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.
That won't work, however, if we plan on supporting manual overriding of the sorting. I would like, for example, to search for phil
and get the ranked sorting. But if I then click on one of the sorting columns, (for example CPU), this should override the search rank.
My solution is hacky so it's a no-go, so let's have a chat about a better solution that addresses all of that.
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.
add a simple condition to the if
should do the trick:
if (filterText != null && sortKey !== "id") {
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.
That means i can't sort my search results alphabetically?
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.
Alphabetically sorting is done before.
https://github.com/mesosphere/marathon-ui/blob/master/src/js/components/AppListComponent.jsx#L315
The sort-function mentioned above should be added below that.
I did a mistake in the condition, must be:
if (filterText != null && sortKey === "id") {
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.
Sorry, the link goes to the wrong view type I think. May bad.
But doesn't change the principle how it works.
An additional sort function should be added here:
https://github.com/mesosphere/marathon-ui/blob/master/src/js/components/AppListComponent.jsx#L301
A test would be neat! :) |
According to the branchname, this is actually a feature and not a fix. |
I had a look at the fuzzaldrin code. Is there is maybe a simpler solution? Maybe just taking a second sorting round only on the applications name without the groups-portion?
Sounds simple. Do I miss something? |
I picked
That is a very useful feature to have in our toolbelt, imho. Imagine searching very nested appIds, without the need to be precise. Regarding performance, I will do some tests. Surely
(I ran We are only using the I agree we should add some tests, and I'll do that next. |
ac4eede
to
bd834f6
Compare
@aldipower I've squashed the changes, please take another look now. Here's a gist that helps you generate a number of fake apps for testing performance and ranking: https://gist.github.com/pierlo-upitup/c325692b3e9511da6590 |
Should we disable the sorting caret for the |
Thanxman! Going to take a second round now. |
Oh yeah. I need to re-generate it... |
@@ -186,7 +187,10 @@ var AppListComponent = React.createClass({ | |||
|
|||
if (filterText != null && filterText !== "") { | |||
nodesSequence = nodesSequence | |||
.filter(app => app.id.indexOf(filterText) !== -1); | |||
.filter(app => { | |||
return score(app.id, filterText) > 0.025; |
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.
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's just a matter of tweaking that 0.25 to something lower, maybe 0.2.
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.
But what sense?
And what else is hidden then unexpected?
Cannot detect the use case for the scoring here.
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 score value is our way of determining matches in the app list for the given filterText. https://github.com/atom/fuzzaldrin#scorestring-query
If we move back to indexOf we lose the whole fuzz matching algorithm completely! Why would you want to do that? I agree that the result not showing up was a regression, but that's because i set the score threshold too high. Please try again 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.
OK, now I got it. You want fuzzy matched results, besides direct matches.
This makes sense.
I was confused because this behavior isn't reflected in the related issue.
It only says that the given results should be ranked better. That's how I understand it.
With this, now, you modify the complete result set.
But I like it!
Confirmative. :)
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.
🎉
@pierlo-upitup OK! Review completed. :) I am fine by going with fuzzaldrin, he is doing a good job. :) And my solution I thought about is too simple, doesn't really work out. This makes the search result way meaningful. |
bd834f6
to
d0a4538
Compare
Thanks for that! I just squashed your requested changes and especially tweaked the score value to 0.02 – that should be fine! Please let me know your thoughts. FTR: I think at some point it might be a really good idea to move this whole filtering logic to the AppsStore or to a new ApssFilterStore because this component is doing far too much! |
Thx, please look at my comment regarding the "0.02". |
@@ -16,6 +16,7 @@ | |||
- \#2831 - Convert alert, confirm and prompt dialogs to new design | |||
- \#2909 - Update dialog messages | |||
- \#2655 - Never preselect dangerous actions in modal dialogs | |||
- \#3018 - Better search result ranking |
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.
Could you be a little bit more precise here? That we do a fuzzy search.
Cool! |
d0a4538
to
5ca3720
Compare
I have removed the caret from the Name column when a filterText is present, as I believe it only generates confusion (you don't order search results on Google...). I've also added some tests. We should be good now! |
@aldipower please take a look at this, for a clarification as to why I think we should not allow Name sorting when showing ranked search results: When i click on the "Name" column, as a user I expect the results sorting by Name. But what this accomplishes, is to sort results by rank in the opposite direction instead. |
@pierlo-upitup Yeah, got what you mean, I would add a hover text on the caret, that explains the sorting by score. |
The health column is also not alphabetically sorted, but ranked! Same thing. Ok, slightly.. ;) |
The Name column works exactly on the id value itself outside of the search page. Sorting by the healthbar is consistent across all other pages, so it's not a good comparison. Why would a user you want to see the worst ranking results first, anyway? |
Take a look at Google Drive.The same is true: sorting by Name is disabled in the search results page. |
OK, the context change is a good argument to me. Thank you for argue this out. The healthbar example wasn't good. |
var filterText = this.props.filters[FilterTypes.TEXT]; | ||
|
||
if (sortKey === this.state.sortKey && | ||
!(sortKey === "id" && filterText != null && filterText !== "")) { |
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.
Sorry for bothering you, could we negate this?
(sortKey !== "id" || filterText == null || filterText === "")) {
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.
forcepushed, sir!
5ca3720
to
9c6f965
Compare
Thank you for the tests, very cool! |
9c6f965
to
2a0b491
Compare
Aahaha and of course coveralls.io decided to die on us on the first PR with some tests 😛 |
LOL |
This fixes mesosphere/marathon#3018
The Name column should not be sortable when looking at ranked search results
464a932
to
4215d80
Compare
Mission accomplished! |
Better ranked search results in app list
This fixes mesosphere/marathon#3018
ACs
From:
To: