Class: Stellr::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/stellr/client.rb

Overview

Stellr client

This class acts as a wrapper around the connection to a Stellr server. Typical usage looks like this:

stellr = Stellr::Client.new('druby://myserver.com:9000')
collection = stellr.connect('myindex', :fields => { :content => { :store => :yes } })
collection << { :content => 'lorem ipsum' }
collection.switch
results = collection.search('lorem', :page => 1, :per_page => 10)

Instance Method Summary collapse

Constructor Details

#initialize(drb_uri) ⇒ Client

Returns a new instance of Client.



19
20
21
# File 'lib/stellr/client.rb', line 19

def initialize( drb_uri )
  @server = DRbObject.new(nil, drb_uri)
end

Instance Method Details

#connect(collection_name, options = nil) ⇒ Object

connects to a remote collection and returns a stub that can be used to add records to the collection and to search for them.

specify an array of collection names for the first argument to search multiple connections at once. No indexing is possible with such a MultiCollection.



29
30
31
32
33
34
35
36
# File 'lib/stellr/client.rb', line 29

def connect( collection_name, options = nil )
  if Array === collection_name
    multi_connect collection_name, options
  else
    @server.register collection_name, options
    ClientCollection.new @server, collection_name
  end
end

#multi_connect(collection_names, options = {}) ⇒ Object

Connects to multiple remote collections at once on order to run cross-collection searches.



40
41
42
# File 'lib/stellr/client.rb', line 40

def multi_connect( collection_names, options = {} )
  MultiCollection.new @server, collection_names, options
end