Module: Litesearch::Model::ActiveRecordClassMethods
- Defined in:
- lib/litestack/litesearch/model.rb
Instance Method Summary collapse
- #create_instance(row) ⇒ Object
- #fetch_row(id) ⇒ Object
- #get_connection ⇒ Object
- #search(term) ⇒ Object
Instance Method Details
#create_instance(row) ⇒ Object
135 136 137 |
# File 'lib/litestack/litesearch/model.rb', line 135 def create_instance(row) instantiate(row) end |
#fetch_row(id) ⇒ Object
119 120 121 |
# File 'lib/litestack/litesearch/model.rb', line 119 def fetch_row(id) find(id) end |
#get_connection ⇒ Object
115 116 117 |
# File 'lib/litestack/litesearch/model.rb', line 115 def get_connection connection.raw_connection end |
#search(term) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/litestack/litesearch/model.rb', line 123 def search(term) self.select( "#{table_name}.*" ).joins( "INNER JOIN #{index_name} ON #{table_name}.id = #{index_name}.rowid AND rank != 0 AND #{index_name} MATCH ", Arel.sql("'#{term}'") ).select( "-#{index_name}.rank AS search_rank" ).order( Arel.sql("#{index_name}.rank") ) end |