Magento – CatalogSearch results looking for partial SKU

catalogsearchelasticsearchmagento2searchsearch-criteria

I need to be able to search by partial string of a SKU, for example, if a SKU of a product is "CUS123.5NYS" the customer may also be able to search by "123.5N", but currently, it only works if I search by initial or end part of the string.

Is it possible to allow search by partial string using some interceptor or preference to override a class?

In the Store configuration I'm using Elasticsearch 5.0+ as Search Engine

Best Answer

By default magento doesn't use wildcards (*123.5N*) with ES. Query building logic implemented in class Magento\Elasticsearch\SearchAdapter\Query\Builder\Query (need change query type to query_string).

Related Topic