2
我想快速确定存储在Vertica中的数据库中包含某个关键字的表和列。 Vertica为全文搜索提供Text Index功能。但是,文本索引只能针对特定的架构/关系而不是整个数据库。在Vertica的数据库中全局创建倒排索引
有谁知道是否有一种简单的方法来为Vertica中的整个数据库构建倒排索引?
我想快速确定存储在Vertica中的数据库中包含某个关键字的表和列。 Vertica为全文搜索提供Text Index功能。但是,文本索引只能针对特定的架构/关系而不是整个数据库。在Vertica的数据库中全局创建倒排索引
有谁知道是否有一种简单的方法来为Vertica中的整个数据库构建倒排索引?
您无法创建跨越多个对象的单个文本索引。每个索引只是一个索引,仅用于表格上的单个列。
你也许可以通过查找列表中的列来生成你想要的创建(尽管老实说完成它们是不常见的)。这假定每个表都有一个名为id
的PK。我只是想简化。
select 'create text index ' || table_schema || '.t_' || table_name || '_' || column_name
|| '_index on ' || table_schema || '.' || table_name
|| '(id,' || column_name || ');'
from columns
where data_type ilike '%char';
然后,您可以创建一个视图,从所有文本索引中进行选择。尽管如此,我不知道这样做会有多好。人们会认为优化器会做它需要的,但很难肯定地说。这可以与上面的查询类似地生成,并且在完成时看起来像这样(注意,如果你是分区,则需要为其添加列)。
create view v_all_text_indexes
as
select 'schema1' schema_name, 'table1' table_name, 'column1' column_name, word, doc_id
from schema1.t_table1_column1_index
union all
select 'schema1' schema_name, 'table1' table_name, 'column2' column_name, word, doc_id
from schema1.t_table1_column2_index
.
.
.
select 'schema1' schema_name, 'tablen' table_name, 'columnn' column_name, word, doc_id
from schema1.t_tablen_columnn_index
我不知道这会为您执行多好,但。因人而异。
如果我误解了这个问题,请告诉我。 – woot
你明白我的问题。谢谢。事实上,我想出了一个类似的解决方案。如果存在性能问题,我会通知您。 –
只要确保'union all'而不是'union'。你可能知道这一点,但只是想我会说出来以防万一。 – woot