Skip to content

Instantly share code, notes, and snippets.

@allaire
Created May 16, 2013 13:37
Show Gist options
  • Save allaire/5591790 to your computer and use it in GitHub Desktop.
Save allaire/5591790 to your computer and use it in GitHub Desktop.
PgSearch.multisearch_options = {
:using => { tsearch: { prefix: true } }
}
module PgSearch
class Document < ActiveRecord::Base
before_save do
self.organization_id = searchable.organization_id
end
end
end
PgSearch::Multisearch::Rebuilder.send(:remove_const, :REBUILD_SQL_TEMPLATE)
module PgSearch
module Multisearch
class Rebuilder
private
REBUILD_SQL_TEMPLATE = <<-SQL.strip_heredoc
INSERT INTO :documents_table (searchable_type, searchable_id, content, created_at, updated_at, organization_id)
SELECT :model_name AS searchable_type,
:model_table.id AS searchable_id,
(
:content_expressions
) AS content,
:current_time AS created_at,
:current_time AS updated_at,
:model_table.organization_id
FROM :model_table
SQL
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment