Module: RSolr::Ext::Client

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

Instance Method Summary collapse

Instance Method Details

#count(*args) ⇒ Object

A simple helper method to return an integer value for the count of resulting rows for the specified query.



29
30
31
32
33
# File 'lib/rsolr-ext/client.rb', line 29

def count *args
  path, params, opts = rsolr_request_arguments_for(*args)
  path ||= "select"
  find(path, params.merge(:rows => 0), opts).total
end

#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
23
24
25
# File 'lib/rsolr-ext/client.rb', line 14

def find *args
  path, params, opts = rsolr_request_arguments_for(*args)
  path ||= "select"
  # send path, map params and send the rest of the args along
  if params[:page] || params[:per_page]
    response = self.paginate params[:page], params[:per_page], path, opts.merge({ :params => RSolr::Ext::Request.map(params) })
  else
    response = self.send_and_receive path, opts.merge({ :params => RSolr::Ext::Request.map(params) })
  end
  
  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.



45
46
47
48
49
50
# File 'lib/rsolr-ext/client.rb', line 45

def luke *args
  path, params, opts = rsolr_request_arguments_for(*args)
  path ||= "admin/luke"
  params['numTerms'] ||= 0
  self.get(path, opts.merge(:params => params)).to_mash
end

#ping(*args) ⇒ Object

sends request to /admin/ping



53
54
55
56
57
# File 'lib/rsolr-ext/client.rb', line 53

def ping *args
  path, params, opts = rsolr_request_arguments_for(*args)
  path ||= "admin/ping"
  self.get(path, opts.merge(:params => 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)


70
71
72
# File 'lib/rsolr-ext/client.rb', line 70

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