0

I have problem when search full text search.

1.First, when I search key have no unicode character, it return exact result.

$type = 'text';

$pattern = 'okman';

$nodes = Node::query()->whereRaw(" MATCH(pattern) AGAINST('$pattern') AND type = '$type' ")->get($columns);

The logged query

select * from bot_nodes where MATCH(pattern) AGAINST('okman') AND type = 'text'

2.Then when I search key have unicode character, it return empty result.

$type = 'text';
$pattern = 'nghỉ đi';
$nodes = Node::query()->whereRaw(" MATCH(pattern) AGAINST('$pattern') AND type = '$type' ")->get($columns);

The logged query:

select * from bot_nodes where MATCH(pattern) AGAINST('nghỉ đi') AND type = 'text'.

But when I copy the above query, and paste it to navicat to run, it return exact query.

I already set charset and collation is utf8mb4 in database.php.

Please help me, thank you.

kevin
  • 105
  • 2
  • 8
  • [Is this what you are looking for?](https://stackoverflow.com/questions/26507087/escape-string-for-use-in-mysql-fulltext-search) or [this](https://github.com/laravel/framework/issues/214)? – Rahul Sep 26 '17 at 10:00
  • Thanks. But I used the raw query like Taylorotwell said. I would like to search with unicode character in the key word. With key word doesn't have unicode character, It run okay – kevin Sep 26 '17 at 10:16
  • Works for me. Please provide the `COLLATION` via `SHOW CREATE TABLE bot_nodes`. Also, what version of MySQL? – Rick James Sep 26 '17 at 22:42
  • And... Do you have In the file config/database.php: 'mysql' => [..., 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', ...] – Rick James Sep 26 '17 at 22:43
  • And... What version of Navicat? See https://stackoverflow.com/questions/39983996/php-mysql-site-using-utf8mb4-wont-retrieve-emojis-correctly-from-database-desp – Rick James Sep 26 '17 at 22:43
  • hi @RickJames. I use Navicat version 11.0.8, MariaDB version 10.1.19 (2016). In config/database.php, I have already set is utf8mb4. – kevin Sep 27 '17 at 02:48
  • the query when create table bot_nodes too long, I cannot show all. This is the collation when create that table: CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci – kevin Sep 27 '17 at 02:51
  • The database and table are one thing. The "connection" is another. – Rick James Sep 27 '17 at 05:36

0 Answers0