GraphQL API. How to do a search like "tags that start with ....." I can't use "*"

Hi, I have read https://shopify.dev/api/usage/search-syntax but I can get a solution.

I want to list all products with a tag that starts with some text:

query MyQuery {
  products(first: 5, , query: "tag:YEAR202*") {
    edges {
      cursor
      node {
        id
        vendor
      }
    }
    pageInfo {
      hasNextPage
    }
  }
}

Imagine that I want to list all products that are from year 2020, 2021 and 2022. (this is an example, please not say me about > or <, and image that I have lot of options so I can’t to several different calls to API)

With query: “tag:YEAR2020” works fine, but query: “tag:YEAR202*” doesn’t.

I can’t do three queries (“tag:YEAR2020”, “tag:YEAR2021”, “tag:YEAR2022” or use “or’s”) in my case because I have more than ten possibilities and changing every time.

Is not possible to do this kind of queries?

I have found that this returns results, (products(first: 5, , query: “YEAR202*”) {) but I think that it is serach for “YEAR202” string in title, description, tags, and so on. And it is very risky.

Please could anyone help me?

Thanks.

2 Likes

Just checking in as I’m looking for the same answer - until we have one, the best approach is probably to use the wildcard, then filter the results with stricter logic.