skip to Main Content

I want to query the product using product tag, but it returned similar product tags with the given tags. I Refer some other references, it denotes the tag are tokenized field so it will return product, if any equality exists in the tags. but i want know if any possibility are there to retrieve the exact tag products

Query

query Myquery{
products(first:10, query: "tag:Switches variants.price:>=2335 variants.price:<=3000") {
    edges {
      node {
        id
        tags 
        variants(first:10)
        {
            edges
          {
            node
            {
                price 
            }
          }
        }
      }
      cursor
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
  }
}

Above query returns tag ‘Switches’ and ‘Switches & Sockets’ but i need tag with ‘Switches’ alone

2

Answers


  1. You understand that tags are a string right? So if you search for the string Switches you will get back Switches, and anything else in the string. So you have the extra step of further processing your results. Split on comma into an array, and only return the products where the filter condition is equal to Switches alone.

    Login or Signup to reply.
  2. You can add an exclusion but you need to know what to exclude e.g.:

    {
      products(first:10, query: "tag:Switches -tag:Sockets") {
        edges {
          node {
            id
            tags 
            variants(first:10)
            {
                edges
              {
                node
                {
                    price 
                }
              }
            }
          }
          cursor
        }
        pageInfo {
          hasNextPage
          hasPreviousPage
        }
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search