Skip to content

How to override default products search

I need to override default graphq products search to allow typos, so that queries like that:

{
    products(
        search: "test"
    ) {
        items {
            name
        }
    }
}
{
    products(
        search: "tets"
    ) {
        items {
            name
        }
    }
}

return same results, I also need them to work with synonyms as well

I’m getting the idea I could replace the elastic query with something like that:

{
    "query": {
        "fuzzy": {
            "name": "tets"
        }
    }
}
  1. What classes should I override to accomplish that?

  2. How to make it work with synonyms too