MySQL Full Text Period

后端 未结 2 1430
逝去的感伤
逝去的感伤 2021-01-24 05:23

I have a table of product names, and full text works great up until using a period, e.g. searching for a 3.7 battery.. i try

select .. where match(name) against          


        
2条回答
  •  心在旅途
    2021-01-24 05:32

    where match(name) against ('+battery' in boolean mode)
      AND name LIKE '%3.7v%'
    

    This requires some intelligence in your app when constructing the query.

    Other variants:

    This makes sure the 3.7v is next to battery:

    where match(name) against ('+battery' in boolean mode)
      AND name LIKE '%3.7v battery%'
    

    This makes sure it has word boundaries around it:

    where match(name) against ('+battery' in boolean mode)
      AND name REGEXP '[[:<:]]3.7v[[:>:]]'
    

提交回复
热议问题