Help with a Custom Collection

Hello - may I ask for help with this one:

I tried to add a custom collections with all cards which have a specific tag and where a number in the body of the card is between a specific range … but I can’t get it to work … even with using AI Superpowers.

Not surprised the collection creator was not able to help with this, as that is unfortunately not possible with the existing filter system. The issue is that because “markup” is a string, you can only perform string operations on it. Substrings within the markup that happen to be numbers are still just strings. This is why for the markup you can only check for equality / contains / within.

Adding such a filter would require parsing the content of all your cards and checking to see if there are numbers, and if there numbers then allow the user to perform number operations on them, which is all just a bit too messy.

However, depending on what type of range we’re talking about, what you can do is have a somewhat exhaustive series of contains filters to check your entire range, one number at a time.

If you wanted cards with a specific tag and a number somewhere between 3-7, it would look like this.

{
  "type": "group",
  "op": "and",
  "filters": [
    {
      "type": "tag",
      "op": "contains",
      "arg": "numeric"
    },
    {
      "type": "group",
      "op": "or",
      "filters": [
        {
          "type": "markup",
          "op": "contains",
          "arg": "3"
        },
        {
          "type": "markup",
          "op": "contains",
          "arg": "4"
        },
        {
          "type": "markup",
          "op": "contains",
          "arg": "5"
        },
        {
          "type": "markup",
          "op": "contains",
          "arg": "6"
        },
        {
          "type": "markup",
          "op": "contains",
          "arg": "7"
        }
      ]
    }
  ]
}

While this obviously can work for a small range of numbers, I certainly wouldn’t do this for a range like 1-100 as I think the performance would suffer in all sorts of ways.

What range were you wanting to find? :sweat_smile:

Thanks connor!

Let’s say I have a card that summarizes the content of my practice exam. It says something like: “Revocation, right of purchase, warranty for defects” and then, for example, § 355 BGB or § 433 BGB.
Now there is, for example, the area §§ 355 - 361, but also §§ 433 - 480. In this regard, I tried to narrow down the area with the “less_than_or_equal” and “greater_than_or_euqal” filters.

However, I could also filter according to the key areas.

Gotcha, that makes sense. I probably would not do the above thing then for that use case, but unfortunately with existing filters there isn’t a better way to do this.

We will have a think to see if we can’t come up with a good way to scratch this itch, but this one in particular looks like a tough one.

1 Like

I do also have a similar use case not with legal textes but with book pages of science literature. What about setting this as a free defined special tag (a kind of a open variable?) in the text? Just as an idea.