-
Notifications
You must be signed in to change notification settings - Fork 400
Support exclusion filters in beatmap search query #12148
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
base: master
Are you sure you want to change the base?
Support exclusion filters in beatmap search query #12148
Conversation
e5672e8 to
02750db
Compare
02750db to
b1a66b9
Compare
|
I recall it being mentioned mapper tags are usually used for titles, genres, etc; basically duplicating the existing fields but with extra variations on the names, so maybe exclude options should duplicate into the mapper tags as well 🤔 |
|
general exclusion query currently doesn't work quite as expected anyway... which is supposed to be fixed by the closed pr (or my workaround pr or... just don't search user tags for general query?). |
nanaya
left a comment
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.
still checking
| foreach ($parser->includes as $optionKey => $optionValue) { | ||
| $propName = $optionMap[$optionKey] ?? null; | ||
|
|
||
| if ($propName !== null) { | ||
| $this->$propName = $optionValue; | ||
| $this->includes->$propName = $optionValue; | ||
| } | ||
| } | ||
|
|
||
| foreach ($parser->excludes as $optionKey => $optionValue) { | ||
| $propName = $optionMap[$optionKey] ?? null; | ||
|
|
||
| if ($propName !== null) { | ||
| $this->excludes->$propName = $optionValue; |
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.
move this to BeatmapsetSearchOptions? And maybe set it right away when parsing the query?
| // Some locales have `,` as decimal separator. | ||
| // Note that thousand separator is not (yet?) supported. | ||
| $value = str_replace(',', '.', $value); | ||
| $value = str_replace(',', '.', (string) $value); |
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.
can use update to strtr
| ->filter(['term' => ['beatmaps.playmode' => Beatmap::MODES['mania']]]); | ||
| if ($this->excludes->keys !== null) { | ||
| // TODO: needs checking; exclude keys but only on mania maps | ||
| // TODO: this seems to make no sense to apply across a whole set? |
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.
no it doesn't. I think this should always imply filtering to just mania maps.
| if ($include) { | ||
| $this->query->must($subQuery); | ||
| } else { | ||
| $this->nestedMustNot->should($subQuery); |
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.
| // require exact match for full tags, partial otherwise. | ||
| // "grid snap" - match grid AND snap in any order. e.g. snap/grid is allowed. | ||
| // ""grid snap"" - match anything with "grid snap". | ||
| // "geometric/grid snap" - explicitly match the tag. |
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.
I'd say just
- partial search on zero or one quote (
tag=thing,tag="thing") - exact search on two quotes (
tag=""thing"")
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Libraries\Search; |
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.
maybe give the beatmap params related classes their own namespace
| $this->query->filter(['terms' => ['track_id' => $trackIds]]); | ||
| } | ||
|
|
||
| if ($this->excludes->featuredArtist !== null) { |
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.
d3b293e to
5dabc24
Compare
|
Updating this with tests, etc on a different branch so this PR doesn't fill with random commits |
0d74a21 to
3bc77f4
Compare
1438bb6 to
2c0a6f4
Compare
7003037 to
96ce084
Compare
|
(more) rebasing and stuff |
96ce084 to
b09dd46
Compare
must_not matching fields, not what we had before
…set to match before excluding
edba3cb to
797ef53
Compare




instead of #12134
fixes #12084
fixes #10916
Support exclusion filters. (
-tag="blah blah")Tags only exclude beatmapsets if all the beatmaps in the beatmapset contain the matching tag(s)
Keyword exclusions are full word only;
bricwill not excludebrick. Keyword exclusions also only excludes the more visible parts of the search results: title, artist, creator; it doesn't exclude fields that are likely to result in a high chance of unintended filtering.Removes blindly feeding the keywords portion of the search query into
simple_query_stringand use proper match query that matches our query syntax, instead of trying to contort it intosimple_query_string.Moves the filters into a separate class.
Fix missing type hints and
strict_typesChose not to include the keyword parsing parts, as a query like
cat -freemight have unintended consequences of excluding all maps that havefreeany where in the searchable fields. Exclusions should explicitly use the-tag=free -title=freesyntax to filter them out from the fields where they are not wanted.Only tags support multiple include/exclusion at the moment; will look at updating the others later