在 Rails 应用程序中使用 Postgres(使用 pg_search gem),我启用了使用 tsvector 的搜索。在拥有超过 35,000 条记录的数据库中,我收到几条消息说
NOTICE: word is too long to be indexed
DETAIL: Words longer than 2047 characters are ignored.
我假设“单词”不包括空格是正确的吗?我如何确定哪些记录导致了此消息?
这是引入索引的迁移生成的 SQL
== AddIndexForFullTextSearch: migrating ======================================
-- add_column(:posts, :tsv, :tsvector)
-> 0.0344s
-- execute(" CREATE INDEX index_posts_tsv ON posts USING gin(tsv);\n")
-> 0.1694s
-- execute(" UPDATE posts SET tsv = (to_tsvector('english', coalesce(title, '')) || \n to_tsvector('english', coalesce(intro, '')) || \n to_tsvector('english', coalesce(body, '')));\n")
NOTICE: word is too long to be indexed
DETAIL: Words longer than 2047 characters are ignored.
NOTICE: word is too long to be indexed
DETAIL: Words longer than 2047 characters are ignored.
NOTICE: word is too long to be indexed
DETAIL: Words longer than 2047 characters are ignored.
NOTICE: word is too long to be indexed
DETAIL: Words longer than 2047 characters are ignored.
-> 343.0556s
-- execute(" CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE\n ON posts FOR EACH ROW EXECUTE PROCEDURE\n tsvector_update_trigger(tsv, 'pg_catalog.english', title, intro, body);\n")
-> 0.0266s