pg_search
pg_search copied to clipboard
Adding dynamic for "associated against" option
We are working with multi-tenant application and we are in need of having dynamic search fields based on the account preference.
Dynamic columns of the same model(against option) works well with the Dynamic search scopes. I tried the same for the associated against option and that is not working.
pg_search_scope :search_by_employee, lambda { |against, associated_against, query|
{
against: against,
associated_against: associated_against
query: query,
using: { tsearch: { prefix: true }, trigram: { word_similarity: true, threshold: 0.3 } },
ranked_by: ':trigram'
}
}
employees.search_by_employee(['first_name'], ["officer_statuses": ["name"]], params[:search_text])
I am getting below error for the above code,
PG::UndefinedTable - ERROR: invalid reference to FROM-clause entry for table "employees"
LINE 1: ... AS rank FROM "employees" LEFT OUTER JOIN (SELECT "employees...
^
Is there any way to make the associated against option dynamic?
I am stuck on this too. Same error.
It's reproducible if the "employees" relation already joins "officer_statuses". If you get rid of the joins on the initial relation, it works. But in my case I need that initial joins.