class DbTextSearch::FullText::PostgresAdapter
Provides basic FTS support for PostgreSQL.
Runs a `@@ plainto_tsquery` query against a `gist(to_tsvector(…))` index.
@see DbTextSearch::FullText::DEFAULT_PG_TS_CONFIG @api private
Public Class Methods
add_index(connection, table_name, column_name, name:, pg_ts_config:)
click to toggle source
(see AbstractAdapter.add_index
)
# File lib/db_text_search/full_text/postgres_adapter.rb, line 20 def self.add_index(connection, table_name, column_name, name:, pg_ts_config:) expression = "USING gist(to_tsvector(#{pg_ts_config}, #{connection.quote_column_name column_name}))" connection.exec_query quoted_create_index(connection, table_name, name: name, expression: expression) end
Public Instance Methods
search(terms, pg_ts_config:)
click to toggle source
(see AbstractAdapter#search
)
# File lib/db_text_search/full_text/postgres_adapter.rb, line 14 def search(terms, pg_ts_config:) @scope.where("to_tsvector(#{pg_ts_config}, #{quoted_scope_column}) @@ plainto_tsquery(#{pg_ts_config}, ?)", terms.uniq.join(' ')) end