Re: GraphQL Admin API - Search Products by Tag

GraphQL Admin API - Search Products by Tag

ryjansen
Visitor
2 0 4

Hello, I am trying to use your GraphQL Admin API to return the products that match a tag by exact tag name. When I search for products with a query filter of either

query: "tag:\"camera\""

or 

query: "tag:camera"

both of these returns partial results such as "camera-cable", however I would like it to only return products that contain the tag "camera". How would I go about this? Thanks.

Replies 2 (2)

Zameer
Shopify Staff
297 31 90

Hey there,

 

The tags field on a product is tokenized and for tokenized fields, equality exists if the term is found anywhere in the field.

 

Some possible solutions here would be to either perform some sort of additional filtering on your end once the results are returned, to only select the ones that match your query exactly. Alternatively, you can use more specific tags on your products to prevent unwanted overlap.

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

ryjansen
Visitor
2 0 4

Hey Zameer,

 

Thanks for the info. I saw that tokenized fields were searched that way, but wasn't able to find info on which fields are tokenized. What makes tags a tokenized field? Is it because it is a comma separated list?

 

Thanks!