I am using Laravel 4 and have set up the following query:
if(Input::get(\'keyword\')) {
$keyword = Input::get(\'keyword\');
$search = DB::connection()-&g
Only the words and operators have meaning in Boolean search mode. Operators are: +
, -
, > <
, ( )
, ~
, *
, "
, @distance
. After some research I found what word characters are: Upper case, Lower case letters, Numeral (digit) and _
. I think you can use one of two approaches:
Replace all non word characters with spaces (I prefer this approach). This can be accomplished with regex:
$search = preg_replace('/[^\p{L}\p{N}_]+/u', ' ', $keyword);
Replace characters-operators with spaces:
$search = preg_replace('/[+\-><\(\)~*\"@]+/', ' ', $keyword);
Only words are indexed by full text search engine and can be searched. Non word characters isn't indexed, so it does not make sense to leave them in the search string.
References: