Class: XapianDb::IndexWriters::BeanstalkWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/xapian_db/index_writers/beanstalk_writer.rb

Class Method Summary collapse

Class Method Details

.beanstalkObject



37
38
39
# File 'lib/xapian_db/index_writers/beanstalk_writer.rb', line 37

def beanstalk
  @beanstalk ||= Beanstalk::Pool.new([XapianDb::Config.beanstalk_daemon_url])
end

.delete_doc_with(xapian_id, commit = true) ⇒ Object

Remove an object from the index

Parameters:

  • xapian_id (String)

    The document id



27
28
29
# File 'lib/xapian_db/index_writers/beanstalk_writer.rb', line 27

def delete_doc_with(xapian_id, commit=true)
  beanstalk.put( { :task => "delete_doc_task", :xapian_id => xapian_id }.to_json )
end

.index(obj, commit = true, changed_attrs: []) ⇒ Object

Update an object in the index

Parameters:

  • obj (Object)

    An instance of a class with a blueprint configuration



21
22
23
# File 'lib/xapian_db/index_writers/beanstalk_writer.rb', line 21

def index(obj, commit=true, changed_attrs: [])
  beanstalk.put( { :task => "index_task", :class => obj.class.name, :id => obj.id, :changed_attrs => changed_attrs }.to_json )
end

.reindex_class(klass, options = {}) ⇒ Object

Reindex all objects of a given class

Parameters:

  • klass (Class)

    The class to reindex



33
34
35
# File 'lib/xapian_db/index_writers/beanstalk_writer.rb', line 33

def reindex_class(klass, options={})
  beanstalk.put( { :task => "reindex_class_task", :class => klass.name }.to_json )
end