Class: DataMapper::Adapters::FerretAdapter::LocalIndex
- Inherits:
-
Object
- Object
- DataMapper::Adapters::FerretAdapter::LocalIndex
- Defined in:
- lib/ferret_adapter/local_index.rb
Instance Method Summary collapse
- #[](id) ⇒ Object
- #add(doc) ⇒ Object
- #delete(query) ⇒ Object
-
#initialize(options) ⇒ LocalIndex
constructor
A new instance of LocalIndex.
- #search(query, options = {}) ⇒ Object
Constructor Details
#initialize(options) ⇒ LocalIndex
Returns a new instance of LocalIndex.
4 5 6 7 8 |
# File 'lib/ferret_adapter/local_index.rb', line 4 def initialize() @options = @options = { :path => @options[:path], :key => [:id, :_type] } create_or_initialize_index end |
Instance Method Details
#[](id) ⇒ Object
22 23 24 |
# File 'lib/ferret_adapter/local_index.rb', line 22 def [](id) @index[id] end |
#add(doc) ⇒ Object
10 11 12 |
# File 'lib/ferret_adapter/local_index.rb', line 10 def add(doc) @index << doc end |
#delete(query) ⇒ Object
14 15 16 |
# File 'lib/ferret_adapter/local_index.rb', line 14 def delete(query) @index.query_delete(query) end |
#search(query, options = {}) ⇒ Object
18 19 20 |
# File 'lib/ferret_adapter/local_index.rb', line 18 def search(query, = {}) @index.search(query, ).hits.collect { |hit, score| @index[hit.doc] } end |