Not sure how to handle my case with pg_search

129 views
Skip to first unread message

kaspa...@gmail.com

unread,
Aug 1, 2016, 11:47:41 PM8/1/16
to Case Commons Development
So I have two models:

Term and Definition.
A definitions has one term and term can have many definitions. Definition has a specification in it and also the definition it self. Term just has a name.

What i want when searching is that that I have scales like this: term.name = A, definition.specification = B, definition.content = C
I got it allmost working with this:

pg_search_scope :search_full_text, against: {
 content
: 'C',
 specification
: 'B'
}, associated_against: {
 term
: [:name]
}


But the term name does not have a scale now so it's not quite right. But when I try the same with multisearchable then I have a problem with the queries. It will make the first query to the documents table but then when I select the objects out I also need definition to include it's term and term to include it's definitions. From pg_gem documentation I don't quite get it how to do it and also how to add scaled in multisearchable.

Maybe someone has an idea on how to approach this?
Reply all
Reply to author
Forward
0 new messages