-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility of using different multisearchable fields for different tenants? #493
Comments
I have this exact problem at the moment too. After a dive on the source code, it looks like the following things would need to change in able to support it:
This is my current setup that is working. I'm not sure if this would be there recommended way of doing it, and would definitely appreciate feedback from @nertzy or anyone on this approach. lib/extensions/pg_search/document.rbThis adds an additional require 'pg_search'
PgSearch::Document.pg_search_scope(:internal_search, lambda { |*args|
{
query: args.first,
against: [:content, :internal_content],
using: {
tsearch: {
prefix: true,
negation: true,
tsvector_column: ["content_tsvector", "internal_content_tsvector"]
}
}
}
}) Migration to alter the existing pg_search_documents table
that manual create index for searchable concernI use a model concern of A usage example
And then can search doing:
|
I have an application that supports an admin portal and a customer portal. We already use multisearch for the admin portal's search function, and would now like to expose a similar search to customers.
For security reasons, I want the multisearchable fields to be different. For instance, admins should be able to search by phone number, but customers should not.
I thought the easiest way of accomplishing this would be to simply have two different
content
andtsv_content
fields, likecontent_admin
andcontent_customer
, and then specify which one to search. Is this something thatpg_search
supports? Or is there a better way of doing what I'm trying to do?The text was updated successfully, but these errors were encountered: