Class: DbTextSearch::FullText::MysqlAdapter Private

Inherits:
AbstractAdapter show all
Defined in:
lib/db_text_search/full_text/mysql_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.

Note:

MySQL v5.6.4+ is required.

Provides basic FTS support for MySQL.

Runs a ‘MATCH AGAINST` query against a `FULLTEXT` index.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractAdapter

#initialize

Methods included from QueryBuilding

included, #sanitize_sql_like

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 abstract.

Add an index for full text search.

Parameters:

  • connection (ActiveRecord::ConnectionAdapters::AbstractAdapter)
  • table_name (String, Symbol)
  • column_name (String, Symbol)
  • name (String, Symbol)

    index name

  • pg_ts_config (String)

    for Postgres, the TS config to use; ignored for non-postgres.



19
20
21
# File 'lib/db_text_search/full_text/mysql_adapter.rb', line 19

def self.add_index(connection, table_name, column_name, name:, pg_ts_config:)
  connection.add_index table_name, column_name, name: name, type: :fulltext
end

Instance Method Details

#search(terms, pg_ts_config:) ⇒ ActiveRecord::Relation

This method is abstract.

Parameters:

  • terms (Array<String>)
  • pg_ts_config (String)

    a pg text search config

Returns:

  • (ActiveRecord::Relation)


14
15
16
# File 'lib/db_text_search/full_text/mysql_adapter.rb', line 14

def search(terms, pg_ts_config:)
  @scope.where("MATCH (#{quoted_scope_column}) AGAINST (?)", terms.uniq.join(' '))
end