Easiest way to silence “word is too long to be indexed” notices in PostgreSQL

▼魔方 西西 提交于 2019-12-11 04:54:00

问题


I have some SQL statements that cause this to happen:

NOTICE:  word is too long to be indexed
DETAIL:  Words longer than 2047 characters are ignored.

What's the easiest way to not have these notices be generated in the first place? (It's a long story why I'd want to do it that way.)

An example of such a statement is this:

update rev set html = regexp_replace(html,
                         '***=<a href="' || old.url || '">',
                         '<a href="' || new.url || '">',
                         'gi')
        where id in (
            select id
                    from rev
                    where to_tsvector('tags_only', html) @@
                      plainto_tsquery('tags_only','<a href="' || old.url || '">')
        )

It's not the A tags with long urls or anything causing the problem. It's probably embedded CDATA-style graphics. I don't care that they're not indexed, whatever they are. I just want these notices to not occur.


回答1:


If you don't mind suppressing all notices just change PostgreSQL error reporting level. client_min_messages defines lowest level of error/warning/notice messages sent to client, log_min_messages does the same for messages saved in log. Possible values are: DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, INFO, NOTICE, WARNING, ERROR, LOG, FATAL, PANIC

edit:

Disable for this query only: SET LOCAL client_min_messages TO WARNING;

Disable for this session only: SET SESSION client_min_messages TO WARNING;

Disable for this user: ALTER ROLE username SET client_min_messages TO WARNING;



来源:https://stackoverflow.com/questions/12925623/easiest-way-to-silence-word-is-too-long-to-be-indexed-notices-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!