Module: PG::FTS

Defined in:
lib/pg/fts.rb

Class Method Summary collapse

Class Method Details

.catalogObject



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

Yields:



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_queryObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/pg/fts.rb', line 24

def create_key_index_query
  "  CREATE UNIQUE INDEX \"\#{PG::FTS.table}_idx\"\n  ON \"\#{PG::FTS.table}\" (\n    \"document_table\",\n    \"document_id\",\n    \"source_table\",\n    \"source_id\");\n  SQL\nend\n".gsub(/^ {4}/, '')

.create_table_queryObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pg/fts.rb', line 12

def create_table_query
  "  CREATE TABLE \"\#{PG::FTS.table}\" (\n    \"id\" SERIAL,\n    \"document_table\" VARCHAR(255),\n    \"document_id\" INT,\n    \"source_table\" VARCHAR(255),\n    \"source_id\" INT,\n    \"tsv\" TSVECTOR);\n  SQL\nend\n".gsub(/^ {4}/, '')

.create_tsv_index_queryObject



35
36
37
38
39
40
41
# File 'lib/pg/fts.rb', line 35

def create_tsv_index_query
  "  CREATE INDEX \"\#{PG::FTS.table}_tsv_idx\"\n  ON \"\#{PG::FTS.table}\"\n  USING GIN (\"tsv\");\n  SQL\nend\n".gsub(/^ {4}/, '')

.drop {|drop_table_query| ... } ⇒ Object

Yields:



61
62
63
# File 'lib/pg/fts.rb', line 61

def drop
  yield(drop_table_query)
end

.drop_table_queryObject



43
44
45
46
47
# File 'lib/pg/fts.rb', line 43

def drop_table_query
  "  DROP TABLE \"\#{PG::FTS.table}\"\n  SQL\nend\n".gsub(/^ {4}/, '')

.tableObject



4
5
6
# File 'lib/pg/fts.rb', line 4

def table
  'fts'
end

.truncate_table_queryObject



49
50
51
52
53
# File 'lib/pg/fts.rb', line 49

def truncate_table_query
  "  TRUNCATE \"\#{PG::FTS.table}\";\n  SQL\nend\n".gsub(/^ {4}/, '')