Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add fuzzy matching support in room searches #6182

Closed
wants to merge 3 commits into from

Conversation

germain-gg
Copy link
Contributor

Fixes element-hq/element-web#14410

This adds support for fuzzy matching in room searches

This is a rather simplistic approach to it. There might be some UX changes to this, I have open a discussion on the #element-dev:matrix.org channel

@germain-gg germain-gg requested a review from a team June 14, 2021 16:32

constructor() {
constructor(options: IOpts = {}) {
Copy link
Member

Choose a reason for hiding this comment

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

not sure how we feel about this more generally, but making this private fuzzy = false is slightly cleaner and works well with IDEs. The options approach does allow for expandability, however this is internal API and can be changed with relative ease.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if I understand the change that you're suggesting.

As far as I can tell I have created private fuzzy = false and this options parameter is only here to let a developer choose the type of matching the NameFilterCondition should apply

Could you show me an example of what you had in mind instead?

Copy link
Member

Choose a reason for hiding this comment

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

In this case, merging the field declaration with the constructor declaration: constructor(private fuzzy = false) {

It's a little bit cleaner for the API contract this part of the code is after.

src/utils/strings.ts Outdated Show resolved Hide resolved
import { fuzzyMatch } from "../../src/utils/strings";

describe("strings", () => {
describe("fuzzyMatch()", () => {
Copy link
Member

Choose a reason for hiding this comment

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

a test that deals with numbers and symbols interspersed with characters would be nice as well, to ensure the regex cleaning works (of which there doesn't appear to be any?) and that it handles non-ascii well (including emoji).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I have added more test cases to deal with more exotic character set.

I'm not sure if I know what regex cleaning is and what you expect it to do in this scenario?

Copy link
Member

Choose a reason for hiding this comment

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

"regex cleaning" is my horrible way of referring to the action the regex performs. There should be tests to make sure that the regex does the right thing, where the "right thing" is cleaning/sanitizing the input from what I can see.

src/utils/strings.ts Outdated Show resolved Hide resolved
@germain-gg germain-gg requested a review from amshakal June 17, 2021 09:57
@novocaine
Copy link
Contributor

@turt2live bump, can you help clarify some of your comments above please

@turt2live turt2live self-requested a review August 23, 2021 13:11
@turt2live
Copy link
Member

Sorry, I had this one slip through the notifications. A mention or review request will always cut through the sea of notifications I deal with.

@turt2live turt2live removed their request for review August 23, 2021 22:26
@novocaine
Copy link
Contributor

@gsouquet can you please update this ticket to describe the changes you've made so that we can review them from a product and design perspective?

@germain-gg
Copy link
Contributor Author

There are no changes done to the UI at the moment.

What was originally discussed with Amsha is that fuzzy matching is going to yield more results. So we need to agree on a visual representation of what has "matched", and how to sort those results.

One caveat with the sorting is that the room list tags (categories) already provide an option to update the sorting of tiles (either alphabetically or by last activity)

Screen Shot 2021-10-01 at 15 06 33

Filtering with fuzzy matching would potentially override that sorting to bump the more relevant tiles to the top, which could be quite jarring. But that is definitely something to explore and see what would make the most sense with our current design

@amshakal
Copy link

amshakal commented Oct 5, 2021

Yeah, I think it's worth considering to show search results by relevance alone rather than based on activity or A-Z, given that that's how most search works on different platforms.

@germain-gg
Copy link
Contributor Author

This pull request is now stale and should handle the new search experience. We're also not doing this as part of the work to get the new search experience out of beta

@germain-gg germain-gg closed this May 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fuzzy matching when filtering room list
4 participants