简体   繁体   English

PostgreSQL可以在tsvector上进行语音搜索吗?

[英]Could PostgreSQL perform phonetic search over tsvector?

I have a table with four language translated columns. 我有一个包含四个语言翻译列的表。 E. g., if there is, for example, description data, there are four columns in database: description_en , description_de , description_it and description_fr . 例如,如果存在描述数据,则数据库中有四列: description_endescription_dedescription_itdescription_fr

I built an index and tsv::tsvector column gathering all of those columns' data into one tsvector -column. 我建立了一个索引和tsv::tsvector列,将所有这些列的数据收集到一个tsvector列中。

Querying that table with tsv @@ to_tsquery(#{ search_query }) is nice, but I would like to match rows with search_query being misspelled. tsv @@ to_tsquery(#{ search_query })查询该表很好,但是我想用search_query拼写错误的方式匹配行。 In other words, to perform fuzzy search. 换句话说,执行模糊搜索。 Yet, I wish it to be as fast as possible as my table is really huge... 但是,我希望它能尽可能快,因为我的桌子真的很大。

So I am wondering, is it ever possible in Postgres to match my tsv column over metaphone(#{ search_query }, 2) somehow? 所以我想知道,在Postgres中,是否有可能以某种方式通过metaphone(#{ search_query }, 2)匹配我的tsv列?

So, for example, strings Herrenarmbanduhr and heren got matched. 因此,例如,串Herrenarmbanduhrheren得到了匹配。

UPD: I have some... medium amount of translated columns, so matching those with metaphone(column_a, 2) = metaphone(query, 2) OR metaphone(column_b, 2) = metaphone(query, 2)... is a pain for me... UPD:我有一些...已翻译的列,所以与metaphone(column_a, 2) = metaphone(query, 2) OR metaphone(column_b, 2) = metaphone(query, 2)...匹配的列是一个我的痛苦

This is not supported out of the box to my knowledge. 据我所知,不支持开箱即用。

It ought to be possible to write a routine (perhaps a C language function?) to turn a tsvector to something like an array of text values and then use other search functionality to do a phonetic search on those. 应该有可能编写一个例程(也许是C语言函数?)以将tsvector转换为诸如文本值数组之类的东西,然后使用其他搜索功能对它们进行语音搜索。 Since the initial conversion and the phonetic transformation would be immutable you could index the output. 由于初始转换和语音转换是不可变的,因此可以对输出进行索引。

But this is not supported out of the box and would be at least a bit of work. 但是,开箱即用不支持此功能,至少需要一点工作。

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

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