How can I create an equal search query for tags without using includes?

Topic summary

A user is trying to create a Shopify Flow query that matches products with an exact tag (e.g., “stylen_ace jacket”) without also returning products with similar but longer tags (e.g., “stylen_ace jacket patterned”).

The Problem:

  • Using tags:"{{tag}}" returns partial matches, not exact matches
  • The same behavior occurs in Shopify Admin queries using includes logic
  • Only one “stylen_” tag exists per product in this case

Proposed Solutions:

  • Code suggestions using Liquid loops with {% if tags == 'stylen_ace' %} for exact matching were offered but don’t address the core query issue
  • A workaround using tags:"{{the_tag}}" AND tags_not:"{{the_tag}} " (note the space after the second tag) was suggested to limit matches by excluding tags that continue beyond the target phrase

Status: The discussion remains open with no confirmed resolution to force exact tag matching in Flow queries.

Summarized with AI on November 13. AI used: claude-sonnet-4-5-20250929.

Hello!
How can I specify a query for tags that EQUALS and not INCLUDES?

If style is

stylen_ace jacket

This query will return products that have that tag but also products that have

stylen_ace jacket patterned

I see that the query in Shopify Admin works the same way, using includes logic:

Hi @josu24
Add the below code and check if this fulfills the functionality

{% for tags in product.tags %}
      {% if tags contains 'stylen_' %}

          {% break %}
      {% endif %}
    {% endfor %}

No in my case there is never more than one “stylen_” tag, should break it anyway though.
The issue is with the query

tag:"{{ style }}"

Hi @josu24
What exactly do you want the functionality to work?
Like what you are trying to achieve
Another thing is if there is only one stylen_ace tag then you can simply add the below code

{% for tags in product.tags %}
      {% if tags == 'stylen_ace' %}

        {% break %}
      {% endif %}
    {% endfor %}

Query all products that have the exact same “stylen_” tag as the product added:

See https://community.shopify.com/post/2365864 if you want more context! :slightly_smiling_face:

That query will always return partial matches like that and I don’t think there is a way to force it to be exact. That said, you might be able to use tags_not…something like:

tags:"{{ the_tag }}" AND tags_not:"{{ the_tag }} "

Note the space after the second one. I think that should limit searches that match something else, assuming they are always separated by a space.