Storefront GraphQL search query with productFilters not working

Solved

Storefront GraphQL search query with productFilters not working

metroink
Tourist
4 1 0

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 0

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

Reply 1 (1)

metroink
Tourist
4 1 0

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.