Cannot filter products that have at least one tag

DanAtBonify
Shopify Partner
54 4 32

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

Replies 6 (6)

Busfox
Shopify Staff (Retired)
628 49 110

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

 

To learn more visit the Shopify Help Center or the Community Blog.

DanAtBonify
Shopify Partner
54 4 32

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

Busfox
Shopify Staff (Retired)
628 49 110

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.

 

 

To learn more visit the Shopify Help Center or the Community Blog.

gilg
Shopify Partner
31 6 6

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

I make Checkout Promotions on the app store. Native pre & post purchase upsells - used by over 1,800 merchants.
claudek
Visitor
2 0 1

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

ValentinMercier
Tourist
10 1 0

Anyone has a solution for this one ?