Class: DataMapper::Adapters::FerretAdapter::RemoteIndex

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

Defined Under Namespace

Classes: IndexNotFound, SearchError

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RemoteIndex

Returns a new instance of RemoteIndex.



8
9
10
11
12
# File 'lib/ferret_adapter/remote_index.rb', line 8

def initialize(options)
  @options = options

  connect_to_remote_index
end

Instance Method Details

#add(doc) ⇒ Object



14
15
16
# File 'lib/ferret_adapter/remote_index.rb', line 14

def add(doc)
  @index.write [:add, DRb.uri, doc]
end

#delete(query) ⇒ Object



18
19
20
# File 'lib/ferret_adapter/remote_index.rb', line 18

def delete(query)
  @index.write [:delete, DRb.uri, query]
end

#search(query, options) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/ferret_adapter/remote_index.rb', line 22

def search(query, options)
  tuple = [query, options]
  @index.write [:search, DRb.uri, tuple]
  result = @index.take([:search_result, DRb.uri, tuple, nil]).last
  if result == nil
    raise SearchError.new("An error occurred performing this search. Check the Ferret logs.")
  end
  result
end