-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Add exact match support for song select searches #24045
Conversation
@@ -246,6 +272,7 @@ public void TestApplyArtistQueriesWithSpaces() | |||
Assert.AreEqual("really like yes", filterCriteria.SearchText.Trim()); | |||
Assert.AreEqual(3, filterCriteria.SearchTerms.Length); | |||
Assert.AreEqual("name with space", filterCriteria.Artist.SearchTerm); | |||
Assert.That(filterCriteria.Artist.Exact, Is.True); |
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.
Please double check this during review. Currently this change forces all searches like artist="this artist"
to exact mode. The quotes here were used to group the search to be scoped to artist, but not necessarily expecting exact match.
I think this seems fine, but worth double-checking with expectations.
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.
Probably fine until proven otherwise.
Hmm, I don't know about that. I implemented this based on the way quotations work in other search engines / contexts. But maybe for osu!'s context it's fine to change it to match the full context? |
@@ -133,10 +153,23 @@ public bool Matches(string value) | |||
if (string.IsNullOrEmpty(value)) | |||
return false; | |||
|
|||
if (Exact) | |||
return Regex.IsMatch(value, $@"(^|\s){searchTerm}($|\s)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); |
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.
Why is this not just
return Regex.IsMatch(value, $@"(^|\s){searchTerm}($|\s)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); | |
return value.Equals(searchTerm, StringComparison.OrdinalIgnoreCase); |
What's the whitespace-or-string-{start,end} thing doing 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.
because you don't want "you" to match "your"
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.
Okay, so it won't match "your", but it might match "will you", or "you will", or whatever, because what it's trying to do is trying to test full word phrases rather than substrings.
Again, doesn't fix the problem with song with a title of just "you", as typing "you"
will still match a bunch of things with the word "you" in it. It'll be some results less but I imagine still a lot. Probably fine though.
I'm not opposed to having it behave like search engines do, but I am confused by the OP claiming that this solves a need in the linked discussion that this change does not in fact appear to solve. |
A good reason for matching standard implementation is because it's also supported in the same way in elasticsearch (aka beatmap listing and other online components). We could probably add something similar to what the user suggests as a follow up for the specific case they want (ie. |
After the initial confusion has been cleared up this looks to be working pretty well now that I've recalibrated my expectations. Pushed a few minor fixes (4cb122d is particularly important, as not escaping bare user input before putting it into a regex could lead to a runtime crash), but looks good otherwise. Please check though. |
As requested at #24005 (reply in thread). Seemed like a quick one to add and quite beneficial QoL wise so knocked it out.
Of note, this could possibly be implemented in the following code block instead:
osu/osu.Game/Screens/Select/FilterQueryParser.cs
Lines 22 to 35 in a74547c
Only noticed this after writing the version I did. Not sure if it makes more or less sense.