forked from pat/ts-delayed-delta
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing indexes to indices when referring to the plural of index.
- Loading branch information
Showing
6 changed files
with
99 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
# A simple job class that processes a given index. | ||
# | ||
# | ||
class ThinkingSphinx::Deltas::DeltaJob | ||
attr_accessor :indexes | ||
attr_accessor :indices | ||
|
||
# Initialises the object with an index name. | ||
# | ||
# | ||
# @param [String] index the name of the Sphinx index | ||
# | ||
def initialize(indexes) | ||
@indexes = indexes | ||
# | ||
def initialize(indices) | ||
@indices = indices | ||
end | ||
|
||
# Shows index name in Delayed::Job#name. | ||
# | ||
# | ||
def display_name | ||
"#{self.class.name} for #{indexes.join(', ')}" | ||
"#{self.class.name} for #{indices.join(', ')}" | ||
end | ||
|
||
# Runs Sphinx's indexer tool to process the index. Currently assumes Sphinx is | ||
# running. | ||
# | ||
# | ||
# @return [Boolean] true | ||
# | ||
# | ||
def perform | ||
config = ThinkingSphinx::Configuration.instance | ||
output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} --rotate #{indexes.join(' ')}` | ||
|
||
output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} --rotate #{indices.join(' ')}` | ||
puts output unless ThinkingSphinx.suppress_delta_output? | ||
|
||
true | ||
end | ||
end |
26 changes: 13 additions & 13 deletions
26
lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
# A simple job for flagging a specified Sphinx document in a given index as | ||
# 'deleted'. | ||
# | ||
# | ||
class ThinkingSphinx::Deltas::FlagAsDeletedJob | ||
attr_accessor :indexes, :document_id | ||
attr_accessor :indices, :document_id | ||
|
||
# Initialises the object with an index name and document id. Please note that | ||
# the document id is Sphinx's unique identifier, and will almost certainly not | ||
# be the model instance's primary key value. | ||
# | ||
# | ||
# @param [String] index The index name | ||
# @param [Integer] document_id The document id | ||
# | ||
def initialize(indexes, document_id) | ||
@indexes, @document_id = indexes, document_id | ||
# | ||
def initialize(indices, document_id) | ||
@indices, @document_id = indices, document_id | ||
end | ||
|
||
# Updates the sphinx_deleted attribute for the given document, setting the | ||
# value to 1 (true). This is not a special attribute in Sphinx, but is used | ||
# by Thinking Sphinx to ignore deleted values between full re-indexing. It's | ||
# particularly useful in this situation to avoid old values in the core index | ||
# and just use the new values in the delta index as a reference point. | ||
# | ||
# | ||
# @return [Boolean] true | ||
# | ||
# | ||
def perform | ||
config = ThinkingSphinx::Configuration.instance | ||
indexes.each do |index| | ||
|
||
indices.each do |index| | ||
config.client.update( | ||
index, | ||
['sphinx_deleted'], | ||
{@document_id => [1]} | ||
) if ThinkingSphinx.sphinx_running? && | ||
ThinkingSphinx.search_for_id(@document_id, index) | ||
end | ||
|
||
true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.