Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Storefront GraphQL search query with productFilters not working

Solved

Storefront GraphQL search query with productFilters not working

metroink
Tourist
4 1 1

When i try the following query:

 

query searchWithFilters($query: String!, $first: Int, $productFilters: [ProductFilter!]) {
search(query: $query, first: $first, productFilters: $productFilters) {
edges {
node {
... on Product {
handle
}
}
}
}
}

 

With the following variables:

{ "query": "", "first": 100, "productFilters": [{'productMetafield':{"namespace": "mynamespace", "key": "mykey", "value": "myvalue"}}] }

I am getting back 100 products vs the expected 2 that have product metafields with the namespace `mynamespace`, the key `mykey` and the value `myvalue`

 

For each of my product metafields i have defined, i have turned on: 

"Filter in product index" - Adds definition to the filter options in the product index

Why does the query not filter the results?
 

 

Accepted Solution (1)

metroink
Tourist
4 1 1

This is an accepted solution.

SOLVED
I had to install the Search and Discovery App, and setup the appropriate filters before this query would work.

View solution in original post

Replies 2 (2)

metroink
Tourist
4 1 1

This is an accepted solution.

SOLVED
I had to install the Search and Discovery App, and setup the appropriate filters before this query would work.
errcsool
Shopify Partner
2 0 0

Also solved with this method. I think this should be better explained in the docs. I'm using version 2024-07