Class: DataMapper::Adapters::FerretAdapter::LocalIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/ferret_adapter/local_index.rb

Instance Method Summary collapse

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 = 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, options = {})
  @index.search(query, options).hits.collect { |hit, score| @index[hit.doc] }
end