Module: RSolr::Ext::Client

Defined in:
lib/rsolr-ext/client.rb

Instance Method Summary collapse

Instance Method Details

#find(*args) ⇒ Object

TWO modes of arguments:

<request-handler-path>, <solr-params-hash> OR <solr-params-hash>

The default request-handler-path is select

If a hash is used for solr params, all of the normal RSolr::Ext::Request mappings are available (everything else gets passed to solr). Returns a new RSolr::Ext::Response::Base object.



14
15
16
17
18
19
20
21
22
# File 'lib/rsolr-ext/client.rb', line 14

def find *args
  # remove the handler arg - the first, if it is a string OR set default
  path = args.first.is_a?(String) ? args.shift : 'select'
  # remove the params - the first, if it is a Hash OR set default
  params = args.first.kind_of?(Hash) ? args.shift : {}
  # send path, map params and send the rest of the args along
  response = self.send_and_receive path, { :params => RSolr::Ext::Request.map(params) }
  RSolr::Ext::Response::Base.new(response, path, params)
end

#luke(*args) ⇒ Object

TWO modes of arguments:

<request-handler-path>, <solr-params-hash> OR <solr-params-hash>

The default request-handler-path is /admin/luke The default params are numTerms=0

Returns a new Mash object.



34
35
36
37
38
39
# File 'lib/rsolr-ext/client.rb', line 34

def luke *args
  path = args.first.is_a?(String) ? args.shift : 'admin/luke'
  params = args.pop || {}
  params['numTerms'] ||= 0
  self.get(path, params).to_mash
end

#ping(*args) ⇒ Object

sends request to /admin/ping



42
43
44
45
46
# File 'lib/rsolr-ext/client.rb', line 42

def ping *args
  path = args.first.is_a?(String) ? args.shift : 'admin/ping'
  params = args.pop || {:wt => :ruby}
  self.get(path, params).to_mash
end

#ping?Boolean

Ping the server and make sure it is alright

solr.ping?

It returns true if the server pings and the status is OK It returns false otherwise – which probably cannot happen Or raises an exception if there is a failure to connect or the ping service is not activated in the solr server

The default configuration point of the PingRequestHandler in the solr server of ‘/admin/ping’ is assumed.

Returns:

  • (Boolean)


59
60
61
# File 'lib/rsolr-ext/client.rb', line 59

def ping?
  ping['status'] == 'OK'
end