How to allow fulltext searching with hyphens in the search query

前端 未结 5 461
温柔的废话
温柔的废话 2020-12-03 14:57

I have keywords like \"some-or-other\" where the hyphens matter in the search through my mysql database. I\'m currently using the fulltext function.

Is there a way

5条回答
  •  死守一世寂寞
    2020-12-03 15:36

    This might sound off, but after struggling with this for a while, I realised I get the results I wish for by removing the hyphen from the search expression. For instance, if I search for 'word-separated'

    SELECT * FROM table WHERE MATCH(column) AGAINST ('word separated');
    

    returns instances of 'word-separated' as needed. This also returns other instances of separated and word, but adding the + operator to each word achieves the hyphen search.

    SELECT * FROM table WHERE MATCH(column) AGAINST ('+word +separated');
    

提交回复
热议问题