Cannot filter products that have at least one tag

Shopify Partner
8 0 5

I am unable to get products from the Graph API that match:

  • Has at least one tag.

 

Example 1:

products(first: 25, query: "tag:*")...

Will return products that DO NOT have tags.

 

Example 2:

products(first: 25, query: "-tag:''")...

Will return products that DO NOT have tags.

 

Example: 3:

products(first: 25, query: "tag:")...

Works almost perfectly. Returns the only two products that have tags and one random product that doesn't have tags. See below:

 

Screenshot 2019-06-10 14.42.37.png

 

 

From the Search documentation: https://help.shopify.com/en/api/getting-started/search-syntax

 

Exists query
The exists query will match documents with a non-NULL value in the specified field.
query=published_at:*
This query can be combined with a Not Query to find fields missing a value, e.g. -published_at:*

Not sure if there's another way to accomplish this...

0 Likes
Community Manager
Community Manager
618 45 81

Hi @DanAtBonify,

 

I had success using this query.

 

 

{
   products(first: 25, query:"tag:*"){
    edges{
      node{
        id
        tags
      }
    }
  }
}

It looks like you already tried this query, but had different results. If possible, can you share a product id with no tags that shows up when doing this query so I can investigate?

 

Cheers

 

0 Likes
Shopify Partner
8 0 5

Hello,

Here are some product IDs that do not have tags that comes back with that result: 4344309251, 4344309443, 4344310275

 

Screenshot 2019-06-19 17.16.30.png

0 Likes
Community Manager
Community Manager
618 45 81

Thanks for the extra info. I see what you mean. I was also able to replicate on my shop. 

 

I imagine the query I shared is returning products with no tags as they are stored as a blank string, rather than a null value. In any case, I've brought this up as an issue to our engineering team, as I can't find a way to query all products with at least one tag. I'll drop another reply here once I have an update on that issue.

 

 

0 Likes
Highlighted

Any update on this? Recently came across this issue as well and basically have no way to highlight a product with 1 or more tags as it ends up showing products with no tags:

 

Screen Shot 2019-11-16 at 3.39.32 PM.png

 

while null query works fine:

Screen Shot 2019-11-16 at 3.39.45 PM.png

Check out Store Recon on the app store.
0 Likes
New Member
1 0 0

Hello guys,

 

how can I search for all the products without any tag (tag is null)?

 

I am familiar with SQL commands (is null) but here the story seems to be different.

 

Any kind of support is truly appreciated.

 

Thank you

 

Claude

0 Likes