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
stream_search: Split names at both "-" and space. #12075
base: main
Are you sure you want to change the base?
Conversation
Hello @zulip/server-search, @zulip/server-sidebars members, this pull request was labeled with the "area: left-sidebar", "area: search" labels, so you may want to check it out! |
@timabbott I think this first commit is good to solve #9399, and should be safe to merge. I think we could move these changes into the typeahead as a seperate follow up commit. |
378c35d
to
d7a881e
Compare
d7a881e
to
c3afaf7
Compare
@rishig Topic suggestions are improved eg "three-four" shown for "four". Stream suggestions are improved eg "ihrd-infra.." shown for "infra". "pm" will suggest individual pms operator as well as group pms operator "with" will suggest individual pms operator as well as group pms operator |
static/js/stream_sort.js
Outdated
@@ -26,7 +26,8 @@ function filter_streams_by_search(streams, search_term) { | |||
var filtered_streams = _.filter(streams, function (stream) { | |||
return _.any(search_terms, function (search_term) { | |||
var lower_stream_name = stream.toLowerCase(); | |||
var cands = lower_stream_name.split(" "); | |||
// This regex allows us to split at " " and "-" | |||
var cands = lower_stream_name.split(/-| /); |
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.
Tim, thoughts on including a bunch of things here? like -
, _
, /
, :
, etc?
(Though I'm not sure how this interacts with our other stream typeahead searches -- ideally the various methods of searching for streams (here, left sidebar, compose typeahead, streams settings) would have similar logic 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.
We need to be careful about characters that have other meanings. Certainly :
would be a bad choice in typeahead because of overlap with emoji. I think _- /
are the widest set that makes sense.
cool, as a product change I think it's positive. I guess these would show up above other search results? (e.g. if there's someone whose email starts with |
c3afaf7
to
389fd90
Compare
Thinking about this more, I worry this whole implementation is hacky and the wrong approach. Perhaps rather than treating various characters as spaces, we should instead just change the matching algorithm for streams to be "prefix matches, followed by non-prefix textual matches" rather than "prefix matches"? Or possibly "prefix matches, followed by non-prefix textual matches starting with an alphanumeric character" |
@timabbott
but I understand if that's not how we'd want to handle this. Also, am I correct in assuming we'd also want to change the algorithms for the typeahead in the same way? |
I think we should consider doing just straight substring matching. The biggest potential issue of substring matching (too many matches) is also mitigated by the fact that most users won't have more than 50-100 streams. |
389fd90
to
5bce3dd
Compare
I tried this out, based on the suggestions I was getting, I just wanted to confirm with @rishig whether this is what we want or whether the approach Tim suggested would be better. These results (to me) seemed to improve: These results (to me) seemed to have gotten worse: but that may be just because I'm used to our old behavior where I could just type "s" and get "sales" as the first result because it was the only stream that began with "s". Of course, typing "sa" gets me just "sales". If we're fine with these images, then no problems and we can discuss where else we want the same logic to be used.
|
hm, good observation about the 1 letter searches being bad. ok, what do you think about
One nice thing about keeping the order is that pinned streams will naturally come above normal streams, will naturally come above inactive streams. (This is also probably the minimal change we can make to our current behavior, that still resolves the issue.) |
I was thinking:
First: All prefix matches, sorted as per existing order.
Then: All non-prefix substring matches, sorted as per existing order
Is this the same as what you're suggesting?
…On Tue, Apr 16, 2019, 21:54 Rishi Gupta ***@***.*** wrote:
hm, good observation about the 1 letter searches being bad.
ok, what do you think about
- match word prefixes, like Tim suggested
- but keep sort order the same as we have now?
One nice thing about keeping the order is that pinned streams naturally
come above normal streams, naturally come above inactive streams.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12075 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AgPWjExFEOjS6-pOvLhNThQYSSRFddQyks5vhfkfgaJpZM4cgpEP>
.
|
It's different -- in my proposal a non-prefix pinned stream match will appear above a prefix non-pinned stream match. |
Ahh, right, what you're saying makes sense to me.
So something like:
<Prefix match in pinned streams.>
<Non-prefix substring match in pinned streams>
<Prefix match in normal streams.>
<Non-prefix substring match in normal streams>
<Prefix match in dormant streams.>
<Non-prefix substring match in dormant streams>
Would be ideal?
…On Wed, Apr 17, 2019, 01:44 Rishi Gupta ***@***.*** wrote:
It's different -- in my proposal a non-prefix pinned stream match will
appear above a prefix non-pinned stream match.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12075 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AgPWjKEVNxLDIr_7DbuuvEILHLaoB8WBks5vhi8ugaJpZM4cgpEP>
.
|
Not quite that either :). <Prefix and non-prefix matches in pinned streams, alphabetically ordered.> |
Changes phrase_match in common.js to split words at "-" in addition to space. phrase_match is called in 4 places, which are effected as follows: - Stream suggestions are improved eg "ihrd-infra.." shown for "infra". - Topic suggestions are improved eg "three-four" shown for "four". - opperator suggestions are changed: "with" will suggest individual pms as well as group pms "pm" will suggest individual pms as well as group pms - Integration searches will return matches after "-" but this doesn't really affect anything right now as curently there are no integrations with "-" in the display name.
This commit is supposed to be squashed with / replace the first commit from this branch
5bce3dd
to
ab4fe76
Compare
@rishig There was some confusion last we were discussing this, I've pushed the changes that I was experimenting with.
This is exactly what this branch currently is, perhaps it wasn't clear because the screenshots didn't have any pinned streams. Here is an example of that: However, this suffers from the problem I was describing here:
(all the images are how this currently is.) |
yeah, I meant we should only match the beginning of words; sorry that wasn't clear. So, |
@rishig do you mean we should only do prefix matches for the first few letters? Just so the context here hasn't been lost: |
I guess I should have used
Your examples of one letter matches were compelling, so this idea has been abandoned. |
Okay, glad I didn't rewrite that first commit then. @timabbott The second commit (6c37d9c) pushes the changes into a few places, including the typeahead suggestions and a few other places as well, I can make changes there if needed. If these are good then we can just drop the third commit (ab4fe76), I'm leaving it on this branch right now in case you want to see the alternate approach I tried (that we're rejecting from design side). |
Can we just split on any non alpha-numeric character? (whatever the i18n equivalent is). |
Heads up @YashRE42, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
4ec3636
to
88b200c
Compare
Fixes #9399.
Testing Plan:
Added node test case, and screenshot from manual testing are bellow.
GIFs or Screenshots:
I created the following streams:
We get better results for search on "infra"
Other searches are as normal: