Hello,
I need to implement full text search in my project but noticed there is no support for tsvector columns in associated models.
I have a somewhat complex associations where the "main" text to be searched is not in the main model.
Anyway, i went ahead and started implementing something in my fork, but would like to know if there are any thoughts on this.
Summary of my changes so far.
Change of pg_search_scope tsvector_column syntax (the old is still supported so no worries):
pg_search_scope :fast_content_search,
:against => {
tsvector_title_tsearch: { weight: 'A', tsvector_column: true }
},
:associated_against => {
content: {
tsvector_content_tsearch: { weight: 'B', tsvector_column: true }
}
},
using: {
tsearch: {
dictionary: "english",
}
}
The weight is to show support for applying weight to a tsvector, exclude it if your tsvector column already has weight or it does not need to be used.
Added rails migration (required) to support aggregating tsvectors ( adds a function and an aggregate ).
At the moment I have only implemented (and tested) with the tsearch feature, not sure if it will automatically work with the others but I will take a look when I can.