Class: DataMapper::SphinxClient
- Inherits:
-
Object
- Object
- DataMapper::SphinxClient
- Defined in:
- lib/dm-sphinx-adapter/sphinx_client.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#index(indexes = nil, options = {}) ⇒ Object
Index one or more indexes.
-
#initialize(uri_or_options) ⇒ SphinxClient
constructor
A new instance of SphinxClient.
-
#search(query, indexes = '*', options = {}) ⇒ Object
Search one or more indexes.
Constructor Details
#initialize(uri_or_options) ⇒ SphinxClient
Returns a new instance of SphinxClient.
8 9 10 11 |
# File 'lib/dm-sphinx-adapter/sphinx_client.rb', line 8 def initialize() # TODO: Documentation. @config = SphinxConfig.new() end |
Instance Method Details
#index(indexes = nil, options = {}) ⇒ Object
Index one or more indexes.
32 33 34 35 36 37 38 39 |
# File 'lib/dm-sphinx-adapter/sphinx_client.rb', line 32 def index(indexes = nil, = {}) indexes = indexes.join(' ') if indexes.kind_of?(Array) command = @config.indexer_bin command << " --rotate" if running? command << ((indexes.nil? || indexes == '*') ? ' --all' : " #{indexes.to_s}") warn "Sphinx: Indexer #{$1}" if `#{command}` =~ /(?:error|fatal|warning):?\s*([^\n]+)/i end |
#search(query, indexes = '*', options = {}) ⇒ Object
Search one or more indexes.
20 21 22 23 24 25 26 |
# File 'lib/dm-sphinx-adapter/sphinx_client.rb', line 20 def search(query, indexes = '*', = {}) indexes = indexes.join(' ') if indexes.kind_of?(Array) client = Riddle::Client.new(@config.address, @config.port) .each{|k, v| client.method("#{k}=".to_sym).call(v) if client.respond_to?("#{k}=".to_sym)} client.query(query, indexes.to_s) end |