简体   繁体   English

在MySQL中的JSON字段上进行全文搜索

[英]Full text search on JSON field in MySQL

I have some field in my database which are string containing JSON in it. 我的数据库中有一些字段,其中是包含JSON的字符串。
It looks like this: 看起来像这样:

2.0.0-p0 :004 > Event.first.title

      Event Load (0.8ms)  SELECT  `events`.* FROM `events`   ORDER BY `events`.`id` ASC LIMIT 1
     => "{'fr' => 'res', 'en' => 'asdg'}" 

I wanna do a full text-search on this column, but a simple 我想在此专栏中进行全文搜索,但简单

Event.where("title LIKE ?", title)

does not result in anything. 没有任何结果。 I have tried by adding the language key, but it doesn't work. 我已经尝试过通过添加语言键来实现,但是它不起作用。 I'm not really sure how to perform this request (or if it is even possible). 我不太确定如何执行此请求(或什至有可能)。

复制评论中的内容作为答案:

Event.where("title like ?", "%#{title}%")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM