Class: Litesearch::Schema::StandaloneAdapter

Inherits:
BasicAdapter show all
Defined in:
lib/litestack/litesearch/schema_adapters/standalone_adapter.rb

Instance Method Summary collapse

Methods inherited from BasicAdapter

#active_cols_names, #active_field_names, #active_fields, #active_weights, #field_names, #fields, #initialize, #name, #order_fields, #sql_for, #table, #tokenizer_sql, #weights

Constructor Details

This class inherits a constructor from Litesearch::Schema::BasicAdapter

Instance Method Details

#generate_sqlObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/litestack/litesearch/schema_adapters/standalone_adapter.rb', line 2

def generate_sql
  super
  @sql[:move_content] = "ALTER TABLE #{name}_content RENAME TO #{name}_content_temp"
  @sql[:adjust_temp_content] = "UPDATE sqlite_schema SET sql (SELECT sql FROM sqlite_schema WHERE name = '#{name}_content') WHERE name = #{name}_content_temp"
  @sql[:restore_content] = "ALTER TABLE #{name}_content_temp RENAME TO #{name}_content"
  @sql[:rebuild] = "INSERT INTO #{name}(#{name}) VALUES ('rebuild')"
  @sql[:similar] = "SELECT rowid AS id, *, -rank AS search_rank FROM #{name} WHERE #{name} = (#{@sql[:similarity_query]}) AND rowid != :id ORDER BY rank LIMIT :limit"
  @sql[:drop_content_table] = "DROP TABLE #{name}_content"
  @sql[:drop_content_col] = :drop_content_col_sql
  @sql[:create_content_table] = :create_content_table_sql
  @sql[:search] = "SELECT rowid AS id, *, -rank AS search_rank FROM #{name}(:term) WHERE rank !=0 ORDER BY rank LIMIT :limit OFFSET :offset"
end