Class: DbTextSearch::FullText::PostgresAdapter Private
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- DbTextSearch::FullText::PostgresAdapter
- Defined in:
- lib/db_text_search/full_text/postgres_adapter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides basic FTS support for PostgreSQL.
Runs a ‘@@ plainto_tsquery` query against a `gist(to_tsvector(…))` index.
Class Method Summary collapse
-
.add_index(connection, table_name, column_name, name:, pg_ts_config:) ⇒ Object
abstract
private
Add an index for full text search.
Instance Method Summary collapse
- #search(terms, pg_ts_config:) ⇒ ActiveRecord::Relation abstract private
Methods inherited from AbstractAdapter
Methods included from QueryBuilding
Constructor Details
This class inherits a constructor from DbTextSearch::FullText::AbstractAdapter
Class Method Details
.add_index(connection, table_name, column_name, name:, pg_ts_config:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method is abstract.
Add an index for full text search.
20 21 22 23 |
# 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 |
Instance Method Details
#search(terms, pg_ts_config:) ⇒ ActiveRecord::Relation
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method is abstract.
14 15 16 17 |
# 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 |