Skip to content
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

Change tag filter to be partial matching instead of exact #2609

Merged

Conversation

KaelenProctor
Copy link
Contributor

Problem

The tag filter with a string value is doing exact matching, which is less useful that a partial match and if you compare it to name filtering the : operation is for partial not exact matching.

Because the tag filter supports both strings (the tag value matches the string) and numbers (the count of tags) it is not really possible to support both = and : for strings, as that would cause ambiguity in the parser given that all numbers are a subset of a string.

Solution

Update setElementOperation so that the : operator does partial matching of the set element value.

Though setElementOperation is also used in the various legality filters (legality, banned, restricted and variants), the change for : to partial match doesn't affect it because the grammar defines all the possible formats as full strings. Thus even though setElementOperation will be doing a partial match, its equivalent to an exact match given that only the exact format strings are allowed.

Testing

Before

It can match tags that are a single word (no spaces) without quotes:
old-tag-string-exact-match-single-word

But if the tag has a space, double quotes are required (otherwise the filter used is tag:word AND name contains word2)
old-tag-string-quoted-exact-match-necessary-for-spaces

And per the above examples, Tag filter string only does exact matching so "Spell" doesn't match the tags with "Spells matter"
old-tag-string-only-exact-match

After

Now tag does partial match:
new-tag-string-partial-matching

Even with quotes for multiple words:
new-tag-string-partial-matching-with-qoutes

Numeric matching still works:
new-tag-numeric-matching-still-works2
new-tag-numeric-matching-still-works

@dekkerglen dekkerglen merged commit 1e9b741 into dekkerglen:master Feb 13, 2025
1 check passed
@KaelenProctor KaelenProctor deleted the feature/tag-filter-partial-match branch February 14, 2025 13:38
@haganbmj
Copy link
Contributor

haganbmj commented Feb 14, 2025

I'll raise the counterpoint to this PR in that partial matches renders me unable to (individually) filter for certain tags.

I use the tags signed and unsigned, which now means that tag:signed returns both and I need to construct a set of exclusions instead (eg. tag:signed -tag:unsigned) because there isn't an option for performing exact matches.

@KaelenProctor
Copy link
Contributor Author

I'll raise the counterpoint to this PR in that partial matches renders me unable to (individually) filter for certain tags.

I use the tags signed and unsigned, which now means that tag:signed returns both and I need to construct a set of exclusions instead (eg. tag:signed -tag:unsigned) because there isn't an option for performing exact matches.

Thanks for the feedback. To support both cases my initial thought is to change tags:"<phrase>" back to exact match, as that also aligns better with how name filtering works. Per the examples on https://cubecobra.com/filters:

  • goblin blood = cards whose names contain both "blood" and "goblin".
  • "goblin blood" = cards whose names contain exactly "goblin blood".

@dekkerglen Does that sound reasonable to you, or any other ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants