Class: ThinkingSphinx::Deltas::FlagAsDeletedJob

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, document_id) ⇒ FlagAsDeletedJob

Returns a new instance of FlagAsDeletedJob.



6
7
8
# File 'lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb', line 6

def initialize(index, document_id)
  @index, @document_id = index, document_id
end

Instance Attribute Details

#document_idObject

Returns the value of attribute document_id.



4
5
6
# File 'lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb', line 4

def document_id
  @document_id
end

#indexObject

Returns the value of attribute index.



4
5
6
# File 'lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb', line 4

def index
  @index
end

Instance Method Details

#performObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb', line 10

def perform
  return true unless ThinkingSphinx.updates_enabled?
  
  config = ThinkingSphinx::Configuration.instance
  client = Riddle::Client.new config.address, config.port
  
  client.update(
    @index,
    ['sphinx_deleted'],
    {@document_id => [1]}
  ) if ThinkingSphinx.sphinx_running? &&
    ThinkingSphinx::Search.search_for_id(@document_id, @index)
  
  true
end