Skip to content

Conversation

@notbakaneko
Copy link
Collaborator

@notbakaneko notbakaneko commented Apr 25, 2025

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; bric will not exclude brick. 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_string and use proper match query that matches our query syntax, instead of trying to contort it into simple_query_string.

Moves the filters into a separate class.
Fix missing type hints and strict_types

  • rebased off Add Beatmapset search tests #12345
  • migrate relevant exclusion stuff from Better beatmap search query parsing #12134
    Chose not to include the keyword parsing parts, as a query like cat -free might have unintended consequences of excluding all maps that have free any where in the searchable fields. Exclusions should explicitly use the -tag=free -title=free syntax 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

@notbakaneko notbakaneko self-assigned this Apr 25, 2025
@notbakaneko notbakaneko force-pushed the feature/beatmapset-query-excludes branch 3 times, most recently from e5672e8 to 02750db Compare May 9, 2025 09:09
@notbakaneko notbakaneko force-pushed the feature/beatmapset-query-excludes branch from 02750db to b1a66b9 Compare May 16, 2025 06:59
@notbakaneko notbakaneko marked this pull request as ready for review May 16, 2025 07:46
@nanaya
Copy link
Collaborator

nanaya commented May 21, 2025

Also mentioned in #12134 but I think #12084 also includes excluding map tags which this PR doesn't handle?

@notbakaneko
Copy link
Collaborator Author

notbakaneko commented May 21, 2025

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 🤔

@nanaya
Copy link
Collaborator

nanaya commented May 21, 2025

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?).

Copy link
Collaborator

@nanaya nanaya left a comment

Choose a reason for hiding this comment

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

still checking

Comment on lines 238 to 250
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;
Copy link
Collaborator

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);
Copy link
Collaborator

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?
Copy link
Collaborator

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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't seem to give correct result when combined with simple keyword search

Comment on lines 488 to 598
// 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.
Copy link
Collaborator

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;
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure where it went wrong but this doesn't seem to work quite right (168 is a-one):

include filter works as expected

@notbakaneko notbakaneko force-pushed the feature/beatmapset-query-excludes branch from d3b293e to 5dabc24 Compare July 25, 2025 04:31
@peppy peppy moved this from Next up to In Progress in @peppy's untitled project Jul 29, 2025
@notbakaneko notbakaneko marked this pull request as draft August 1, 2025 03:50
@notbakaneko
Copy link
Collaborator Author

Updating this with tests, etc on a different branch so this PR doesn't fill with random commits

@notbakaneko notbakaneko force-pushed the feature/beatmapset-query-excludes branch 2 times, most recently from 0d74a21 to 3bc77f4 Compare August 12, 2025 06:31
@notbakaneko notbakaneko force-pushed the feature/beatmapset-query-excludes branch 2 times, most recently from 1438bb6 to 2c0a6f4 Compare August 26, 2025 02:53
@notbakaneko notbakaneko force-pushed the feature/beatmapset-query-excludes branch from 7003037 to 96ce084 Compare September 8, 2025 22:20
@notbakaneko notbakaneko marked this pull request as ready for review September 9, 2025 12:27
@notbakaneko notbakaneko marked this pull request as draft October 9, 2025 06:35
@notbakaneko
Copy link
Collaborator Author

(more) rebasing and stuff

@notbakaneko notbakaneko force-pushed the feature/beatmapset-query-excludes branch from 96ce084 to b09dd46 Compare November 5, 2025 06:34
@notbakaneko notbakaneko force-pushed the feature/beatmapset-query-excludes branch from edba3cb to 797ef53 Compare December 1, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Excluding map tags from search doesn't work Beatmap search filtering only looks at tags

2 participants