Magento – How does Magento 2 Search work with ‘-‘

magento2search

I have 4 products in catalog with names:

aaa

bbb

aaa-bbb

aaa_bbb

When I try to search "aaa", I get aaa, aaa-bbb and aaa_bbb products as a result (screen 1)
screen 1

When my query is "bbb", I get only bbb and aaa-bbb (screen 2)
screen 2

"aaa-bbb" query gives me all my products (screen 3)
screen 3

And finally query "aaa_bbb" returns me only one product (screen 4)
screen 4

So, can you please explain me how it works and how I can change this logic?
Specifically, I need to get only aaa-bbb product, when I search "aaa-bbb".

Did I understand correctly, Magento search engine explode my query by '-' symbol? I didn't found the confirmation of this in code, but as I see by search results it's looks like true.

Thank you for attention 🙂

Best Answer

Magento by default using MySql based search. So, it is split text on word on by pattern like [^a-z0-9_]. it's why aaa-bbb interpreted as "aaa bbb"

see more details here: http://dev.mysql.com/doc/refman/5.7/en/fulltext-boolean.html