简体   繁体   English

使用PostgreSQL进行批量文本搜索

[英]Batch text search with PostgreSQL

I have a Rails 4 app with PostgreSQL database. 我有一个带有PostgreSQL数据库的Rails 4应用程序。 I use PSQL default full text search for some fields, such as university_name. 我使用PSQL默认全文搜索某些字段,例如university_name。 I need to send hundreds of full text search query at a time against my database. 我需要一次针对数据库发送数百个全文本搜索查询。

Right now, I perform these queries serially, and it is very slow. 现在,我串行执行这些查询,而且速度很慢。 Is there any way I can send text search in batch mode? 有什么方法可以以批处理方式发送文本搜索?

Yes try using the tsvector columns which will 是的,请尝试使用tsvector columns

pg_search#using-tsvector-columns pg_search#using-tsvector-columns

Later you will run the search against the tsv_field instead of the normal text, which will make it faster. 稍后,您将对tsv_field而不是常规文本进行搜索,这将使搜索速度更快。

pg_search_scope :fast_content_search,
                :against => :content,
                :using => {
                  dmetaphone: {
                    tsvector_column: 'tsvector_content_dmetaphone'
                  },
                  tsearch: {
                    dictionary: 'english',
                    tsvector_column: 'tsvector_content_tsearch'
                  }
                  trigram: {} # trigram does not use tsvectors
                }

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

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