I have a Rails 4 app with PostgreSQL database. I use PSQL default full text search for some fields, such as 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
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.
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.