Module: PG::FTS
- Defined in:
- lib/pg/fts.rb
Class Method Summary collapse
- .catalog ⇒ Object
- .clear {|truncate_table_query| ... } ⇒ Object
- .create {|create_table_query| ... } ⇒ Object
- .create_key_index_query ⇒ Object
- .create_table_query ⇒ Object
- .create_tsv_index_query ⇒ Object
- .drop {|drop_table_query| ... } ⇒ Object
- .drop_table_query ⇒ Object
- .table ⇒ Object
- .truncate_table_query ⇒ Object
Class Method Details
.catalog ⇒ Object
8 9 10 |
# File 'lib/pg/fts.rb', line 8 def catalog 'pg_catalog.simple' end |
.clear {|truncate_table_query| ... } ⇒ Object
65 66 67 |
# File 'lib/pg/fts.rb', line 65 def clear yield(truncate_table_query) end |
.create {|create_table_query| ... } ⇒ Object
55 56 57 58 59 |
# File 'lib/pg/fts.rb', line 55 def create yield(create_table_query) yield(create_key_index_query) yield(create_tsv_index_query) end |
.create_key_index_query ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pg/fts.rb', line 24 def create_key_index_query <<-SQL.gsub(/^ {4}/, '') CREATE UNIQUE INDEX "#{PG::FTS.table}_idx" ON "#{PG::FTS.table}" ( "document_table", "document_id", "source_table", "source_id"); SQL end |
.create_table_query ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pg/fts.rb', line 12 def create_table_query <<-SQL.gsub(/^ {4}/, '') CREATE TABLE "#{PG::FTS.table}" ( "id" SERIAL, "document_table" VARCHAR(255), "document_id" INT, "source_table" VARCHAR(255), "source_id" INT, "tsv" TSVECTOR); SQL end |
.create_tsv_index_query ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/pg/fts.rb', line 35 def create_tsv_index_query <<-SQL.gsub(/^ {4}/, '') CREATE INDEX "#{PG::FTS.table}_tsv_idx" ON "#{PG::FTS.table}" USING GIN ("tsv"); SQL end |
.drop {|drop_table_query| ... } ⇒ Object
61 62 63 |
# File 'lib/pg/fts.rb', line 61 def drop yield(drop_table_query) end |
.drop_table_query ⇒ Object
43 44 45 46 47 |
# File 'lib/pg/fts.rb', line 43 def drop_table_query <<-SQL.gsub(/^ {4}/, '') DROP TABLE "#{PG::FTS.table}" SQL end |
.table ⇒ Object
4 5 6 |
# File 'lib/pg/fts.rb', line 4 def table 'fts' end |
.truncate_table_query ⇒ Object
49 50 51 52 53 |
# File 'lib/pg/fts.rb', line 49 def truncate_table_query <<-SQL.gsub(/^ {4}/, '') TRUNCATE "#{PG::FTS.table}"; SQL end |