简体   繁体   English

搜索Postgres JSONB字段

[英]Search Postgres JSONB fields

I want to search the pattern '%myvalue%' in key and value for a json field, return any one that matched. 我想在键和值中搜索模式'%myvalue%'以获得json字段,返回任何匹配的内容。

I use 我用

select * from dialogue_responses where field_rule like '%myvalue%'

it prompts me error 它提示我错误

ERROR:  operator does not exist: jsonb ~~ unknown
LINE 1: select * from dialogue_responses where field_rule like '%auf...
                                                          ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

What's he correct way of doing this? 他这样做的正确方法是什么?

You can cast into text in the query. 您可以在查询中转换为文本。 Such as

select * from dialogue_responses where field_rule::varchar like '%myvalue%'

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

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