thinking-sphinx 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -6
- data/HISTORY +21 -0
- data/lib/thinking_sphinx.rb +1 -0
- data/lib/thinking_sphinx/active_record.rb +1 -0
- data/lib/thinking_sphinx/active_record/base.rb +3 -2
- data/lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb +4 -0
- data/lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb +4 -0
- data/lib/thinking_sphinx/active_record/filtered_reflection.rb +10 -2
- data/lib/thinking_sphinx/active_record/interpreter.rb +2 -1
- data/lib/thinking_sphinx/active_record/join_association.rb +13 -0
- data/lib/thinking_sphinx/active_record/log_subscriber.rb +8 -3
- data/lib/thinking_sphinx/active_record/polymorpher.rb +8 -1
- data/lib/thinking_sphinx/active_record/sql_builder.rb +19 -4
- data/lib/thinking_sphinx/active_record/sql_builder/statement.rb +19 -12
- data/lib/thinking_sphinx/active_record/sql_source.rb +2 -2
- data/lib/thinking_sphinx/capistrano/v3.rb +1 -1
- data/lib/thinking_sphinx/configuration.rb +1 -1
- data/lib/thinking_sphinx/connection.rb +4 -2
- data/lib/thinking_sphinx/controller.rb +3 -13
- data/lib/thinking_sphinx/core/index.rb +13 -3
- data/lib/thinking_sphinx/core/interpreter.rb +4 -0
- data/lib/thinking_sphinx/deletion.rb +5 -3
- data/lib/thinking_sphinx/errors.rb +3 -0
- data/lib/thinking_sphinx/facet.rb +3 -2
- data/lib/thinking_sphinx/facet_search.rb +6 -2
- data/lib/thinking_sphinx/guard.rb +6 -0
- data/lib/thinking_sphinx/guard/file.rb +26 -0
- data/lib/thinking_sphinx/guard/files.rb +38 -0
- data/lib/thinking_sphinx/masks/group_enumerators_mask.rb +4 -4
- data/lib/thinking_sphinx/masks/weight_enumerator_mask.rb +1 -1
- data/lib/thinking_sphinx/middlewares/sphinxql.rb +2 -2
- data/lib/thinking_sphinx/panes/weight_pane.rb +1 -1
- data/lib/thinking_sphinx/rake_interface.rb +20 -1
- data/lib/thinking_sphinx/real_time.rb +2 -2
- data/lib/thinking_sphinx/real_time/callbacks/real_time_callbacks.rb +10 -4
- data/lib/thinking_sphinx/real_time/interpreter.rb +2 -1
- data/lib/thinking_sphinx/real_time/transcriber.rb +1 -1
- data/lib/thinking_sphinx/search.rb +4 -0
- data/lib/thinking_sphinx/search/merger.rb +4 -0
- data/lib/thinking_sphinx/sphinxql.rb +12 -6
- data/lib/thinking_sphinx/tasks.rb +13 -3
- data/spec/acceptance/attribute_access_spec.rb +2 -2
- data/spec/acceptance/big_integers_spec.rb +11 -0
- data/spec/acceptance/facets_spec.rb +4 -1
- data/spec/acceptance/indexing_spec.rb +9 -0
- data/spec/acceptance/specifying_sql_spec.rb +1 -1
- data/spec/acceptance/sphinx_scopes_spec.rb +9 -0
- data/spec/internal/app/indices/user_index.rb +2 -0
- data/spec/thinking_sphinx/active_record/base_spec.rb +3 -1
- data/spec/thinking_sphinx/active_record/index_spec.rb +8 -0
- data/spec/thinking_sphinx/active_record/interpreter_spec.rb +7 -1
- data/spec/thinking_sphinx/active_record/polymorpher_spec.rb +16 -3
- data/spec/thinking_sphinx/configuration_spec.rb +18 -0
- data/spec/thinking_sphinx/facet_search_spec.rb +6 -6
- data/spec/thinking_sphinx/masks/scopes_mask_spec.rb +6 -1
- data/spec/thinking_sphinx/panes/weight_pane_spec.rb +1 -1
- data/spec/thinking_sphinx/rake_interface_spec.rb +62 -3
- data/spec/thinking_sphinx/real_time/callbacks/real_time_callbacks_spec.rb +38 -4
- data/spec/thinking_sphinx/real_time/index_spec.rb +4 -0
- data/spec/thinking_sphinx/real_time/interpreter_spec.rb +7 -1
- data/thinking-sphinx.gemspec +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629217e38872edc12e92be134409a509b84f1304
|
4
|
+
data.tar.gz: 4b19eec90cfe3b560b1fcdd56a7018f07704ec94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5116aad817ad119c97f05ec5bcdf330ca89ecae39ecac5695c4b9573ba062a88e25b6c8db22c596a32ec57ca8c044b2805360696b4b6342196d19b775886e340
|
7
|
+
data.tar.gz: 6923c30ad7163f0ec5c286b5cf98403c27618dc57191bff659808000f9f51bcf2e1ef0eec22fbf6ecc54752a9e1e6474d6e62a65b65db6cc462d8657beae183e
|
data/.travis.yml
CHANGED
@@ -10,12 +10,12 @@ before_script:
|
|
10
10
|
- "mysql -e 'create database thinking_sphinx;' > /dev/null"
|
11
11
|
- "psql -c 'create database thinking_sphinx;' -U postgres >/dev/null"
|
12
12
|
env:
|
13
|
-
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.0.
|
14
|
-
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.0.
|
15
|
-
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.1.
|
16
|
-
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.1.
|
17
|
-
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.2.
|
18
|
-
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.2.
|
13
|
+
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.0.10/bin/ SPHINX_VERSION=2.0.10
|
14
|
+
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.0.10/bin/ SPHINX_VERSION=2.0.10
|
15
|
+
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.1.8/bin/ SPHINX_VERSION=2.1.8
|
16
|
+
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.1.8/bin/ SPHINX_VERSION=2.1.8
|
17
|
+
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.2.2-beta/bin/ SPHINX_VERSION=2.2.2
|
18
|
+
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.2.2-beta/bin/ SPHINX_VERSION=2.2.2
|
19
19
|
gemfile:
|
20
20
|
- gemfiles/rails_3_2.gemfile
|
21
21
|
- gemfiles/rails_4_0.gemfile
|
data/HISTORY
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
2014-11-04: 3.1.2
|
2
|
+
* [CHANGE] regenerate task now only deletes index files for real-time indices.
|
3
|
+
* [CHANGE] Raise an exception when a populated search query is modified (as it can't be requeried).
|
4
|
+
* [FEATURE] Allow for custom paths for index files using :path option in the ThinkingSphinx::Index.define call.
|
5
|
+
* [FIX] Ensure indexing guard files are removed when an exception is raised (Bobby Uhlenbrock).
|
6
|
+
* [FIX] Don't update real-time indices for objects that are not persisted (Chance Downs).
|
7
|
+
* [FEATURE] Allow the binlog path to be an empty string (Bobby Uhlenbrock).
|
8
|
+
* [FIX] Use STI base class for polymorphic association replacements.
|
9
|
+
* [FIX] Convert database setting keys to symbols for consistency with Rails (@dimko).
|
10
|
+
* [FIX] Field weights and other search options are now respected from set_property.
|
11
|
+
* [CHANGE] Log indices that aren't processed due to guard files existing.
|
12
|
+
* [FEATURE] Add status task to report on whether Sphinx is running.
|
13
|
+
* [FIX] Models with more than one index have correct facet counts (using Sphinx 2.1.x or newer).
|
14
|
+
* [FEATURE] Real-time index callbacks can take a block for dynamic scoping.
|
15
|
+
* [FIX] Some association fixes for Rails 4.1.
|
16
|
+
* [CHANGE] Paginate records by 1000 results at a time when flagging as deleted.
|
17
|
+
* [CHANGE] Default the Capistrano TS Rails environment to use rails_env, and then fall back to stage.
|
18
|
+
* [CHANGE] rebuild task uses clear between stopping the daemon and indexing.
|
19
|
+
* [FIX] Clear connections when raising connection errors.
|
20
|
+
* [FEATURE] Allow casting of document ids pre-offset as bigints (via big_documents_id option).
|
21
|
+
|
1
22
|
2014-04-22: 3.1.1
|
2
23
|
* [CHANGE] Include full statements when query execution errors are raised (uglier, but more useful when debugging).
|
3
24
|
* [FEATURE] Allow for common section in generated Sphinx configuration files for Sphinx 2.2.x (disabled by default, though) (Trevor Smith).
|
data/lib/thinking_sphinx.rb
CHANGED
@@ -55,6 +55,7 @@ require 'thinking_sphinx/facet'
|
|
55
55
|
require 'thinking_sphinx/facet_search'
|
56
56
|
require 'thinking_sphinx/float_formatter'
|
57
57
|
require 'thinking_sphinx/frameworks'
|
58
|
+
require 'thinking_sphinx/guard'
|
58
59
|
require 'thinking_sphinx/index'
|
59
60
|
require 'thinking_sphinx/index_set'
|
60
61
|
require 'thinking_sphinx/masks'
|
@@ -17,6 +17,7 @@ require 'thinking_sphinx/active_record/field'
|
|
17
17
|
require 'thinking_sphinx/active_record/filtered_reflection'
|
18
18
|
require 'thinking_sphinx/active_record/index'
|
19
19
|
require 'thinking_sphinx/active_record/interpreter'
|
20
|
+
require 'thinking_sphinx/active_record/join_association'
|
20
21
|
require 'thinking_sphinx/active_record/log_subscriber'
|
21
22
|
require 'thinking_sphinx/active_record/polymorpher'
|
22
23
|
require 'thinking_sphinx/active_record/property_query'
|
@@ -25,8 +25,9 @@ module ThinkingSphinx::ActiveRecord::Base
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def search_for_ids(query = nil, options = {})
|
28
|
-
|
29
|
-
|
28
|
+
ThinkingSphinx::Search::Merger.new(
|
29
|
+
search(query, options)
|
30
|
+
).merge! nil, :ids_only => true
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
@@ -17,7 +17,10 @@ class ThinkingSphinx::ActiveRecord::FilteredReflection <
|
|
17
17
|
@options[:foreign_key] ||= "#{reflection.name}_id"
|
18
18
|
@options[:foreign_type] = reflection.foreign_type
|
19
19
|
|
20
|
-
|
20
|
+
if reflection.respond_to?(:scope)
|
21
|
+
@options[:sphinx_internal_filtered] = true
|
22
|
+
return @options
|
23
|
+
end
|
21
24
|
|
22
25
|
case @options[:conditions]
|
23
26
|
when nil
|
@@ -34,11 +37,16 @@ class ThinkingSphinx::ActiveRecord::FilteredReflection <
|
|
34
37
|
end
|
35
38
|
|
36
39
|
def scope
|
40
|
+
if ::Joiner::Joins.instance_methods.include?(:join_association_class)
|
41
|
+
return nil
|
42
|
+
end
|
43
|
+
|
37
44
|
lambda { |association|
|
38
45
|
reflection = association.reflection
|
46
|
+
klass = reflection.class_name.constantize
|
39
47
|
where(
|
40
48
|
association.parent.aliased_table_name.to_sym =>
|
41
|
-
{reflection.foreign_type =>
|
49
|
+
{reflection.foreign_type => klass.base_class.name}
|
42
50
|
)
|
43
51
|
}
|
44
52
|
end
|
@@ -39,7 +39,7 @@ class ThinkingSphinx::ActiveRecord::Interpreter <
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def set_database(hash_or_key)
|
42
|
-
configuration = hash_or_key.is_a?(::Hash) ? hash_or_key :
|
42
|
+
configuration = hash_or_key.is_a?(::Hash) ? hash_or_key.symbolize_keys :
|
43
43
|
::ActiveRecord::Base.configurations[hash_or_key.to_s]
|
44
44
|
|
45
45
|
__source.set_database_settings configuration
|
@@ -50,6 +50,7 @@ class ThinkingSphinx::ActiveRecord::Interpreter <
|
|
50
50
|
@index.send("#{key}=", value) if @index.class.settings.include?(key)
|
51
51
|
__source.send("#{key}=", value) if __source.class.settings.include?(key)
|
52
52
|
__source.options[key] = value if source_option?(key)
|
53
|
+
@index.options[key] = value if search_option?(key)
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class ThinkingSphinx::ActiveRecord::JoinAssociation <
|
2
|
+
::ActiveRecord::Associations::JoinDependency::JoinAssociation
|
3
|
+
|
4
|
+
def build_constraint(klass, table, key, foreign_table, foreign_key)
|
5
|
+
constraint = super
|
6
|
+
|
7
|
+
constraint = constraint.and(
|
8
|
+
foreign_table[reflection.options[:foreign_type]].eq(base_klass.name)
|
9
|
+
) if reflection.options[:sphinx_internal_filtered]
|
10
|
+
|
11
|
+
constraint
|
12
|
+
end
|
13
|
+
end
|
@@ -1,13 +1,18 @@
|
|
1
1
|
class ThinkingSphinx::ActiveRecord::LogSubscriber < ActiveSupport::LogSubscriber
|
2
|
-
def
|
3
|
-
identifier = color
|
4
|
-
|
2
|
+
def guard(event)
|
3
|
+
identifier = color 'Sphinx', GREEN, true
|
4
|
+
warn " #{identifier} #{event.payload[:guard]}"
|
5
5
|
end
|
6
6
|
|
7
7
|
def message(event)
|
8
8
|
identifier = color 'Sphinx', GREEN, true
|
9
9
|
debug " #{identifier} #{event.payload[:message]}"
|
10
10
|
end
|
11
|
+
|
12
|
+
def query(event)
|
13
|
+
identifier = color('Sphinx Query (%.1fms)' % event.duration, GREEN, true)
|
14
|
+
debug " #{identifier} #{event.payload[:query]}"
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
ThinkingSphinx::ActiveRecord::LogSubscriber.attach_to :thinking_sphinx
|
@@ -14,7 +14,14 @@ class ThinkingSphinx::ActiveRecord::Polymorpher
|
|
14
14
|
|
15
15
|
def append_reflections
|
16
16
|
mappings.each do |class_name, name|
|
17
|
-
klass.reflections[name]
|
17
|
+
next if klass.reflections[name]
|
18
|
+
|
19
|
+
reflection = clone_with name, class_name
|
20
|
+
if ActiveRecord::Reflection.respond_to?(:add_reflection)
|
21
|
+
ActiveRecord::Reflection.add_reflection klass, name, reflection
|
22
|
+
else
|
23
|
+
klass.reflections[name] = reflection
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
20
27
|
|
@@ -34,7 +34,7 @@ module ThinkingSphinx
|
|
34
34
|
|
35
35
|
delegate :adapter, :model, :delta_processor, :to => :source
|
36
36
|
delegate :convert_nulls, :time_zone_query_pre, :utf8_query_pre,
|
37
|
-
:to => :adapter
|
37
|
+
:cast_to_bigint, :to => :adapter
|
38
38
|
|
39
39
|
def query
|
40
40
|
Query.new(self)
|
@@ -53,10 +53,17 @@ module ThinkingSphinx
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def associations
|
56
|
-
@associations ||=
|
56
|
+
@associations ||= begin
|
57
|
+
joins = Joiner::Joins.new model
|
58
|
+
if joins.respond_to?(:join_association_class)
|
59
|
+
joins.join_association_class = ThinkingSphinx::ActiveRecord::JoinAssociation
|
60
|
+
end
|
61
|
+
|
57
62
|
source.associations.reject(&:string?).each do |association|
|
58
|
-
|
63
|
+
joins.add_join_to association.stack
|
59
64
|
end
|
65
|
+
|
66
|
+
joins
|
60
67
|
end
|
61
68
|
end
|
62
69
|
|
@@ -76,9 +83,17 @@ module ThinkingSphinx
|
|
76
83
|
('SQL_NO_CACHE ' if source.type == 'mysql').to_s
|
77
84
|
end
|
78
85
|
|
86
|
+
def big_document_ids?
|
87
|
+
source.options[:big_document_ids] || config.settings['big_document_ids']
|
88
|
+
end
|
89
|
+
|
79
90
|
def document_id
|
80
91
|
quoted_alias = quote_column source.primary_key
|
81
|
-
|
92
|
+
column = quoted_primary_key
|
93
|
+
column = cast_to_bigint column if big_document_ids?
|
94
|
+
column = "#{column} * #{config.indices.count} + #{source.offset}"
|
95
|
+
|
96
|
+
"#{column} AS #{quoted_alias}"
|
82
97
|
end
|
83
98
|
|
84
99
|
def reversed_document_id
|
@@ -4,8 +4,8 @@ module ThinkingSphinx
|
|
4
4
|
module ActiveRecord
|
5
5
|
class SQLBuilder::Statement
|
6
6
|
def initialize(report)
|
7
|
-
|
8
|
-
|
7
|
+
@report = report
|
8
|
+
@scope = relation
|
9
9
|
end
|
10
10
|
|
11
11
|
def to_relation
|
@@ -32,8 +32,9 @@ module ThinkingSphinx
|
|
32
32
|
scope
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
private
|
36
|
+
|
37
|
+
attr_reader :report, :scope
|
37
38
|
|
38
39
|
def custom_joins
|
39
40
|
@custom_joins ||= source.associations.select(&:string?).collect(&:to_s)
|
@@ -43,11 +44,13 @@ module ThinkingSphinx
|
|
43
44
|
minimum = convert_nulls "MIN(#{quoted_primary_key})", 1
|
44
45
|
maximum = convert_nulls "MAX(#{quoted_primary_key})", 1
|
45
46
|
|
46
|
-
|
47
|
+
@scope = scope.select("#{minimum}, #{maximum}").where(
|
48
|
+
where_clause(true)
|
49
|
+
)
|
47
50
|
end
|
48
51
|
|
49
52
|
def filter_by_query_info
|
50
|
-
|
53
|
+
@scope = scope.where("#{quoted_primary_key} = #{reversed_document_id}")
|
51
54
|
end
|
52
55
|
|
53
56
|
def filter_by_scopes
|
@@ -86,27 +89,31 @@ module ThinkingSphinx
|
|
86
89
|
end
|
87
90
|
|
88
91
|
def scope_by_select
|
89
|
-
|
92
|
+
@scope = scope.select(pre_select + select_clause)
|
90
93
|
end
|
91
94
|
|
92
95
|
def scope_by_where_clause
|
93
|
-
|
96
|
+
@scope = scope.where where_clause
|
94
97
|
end
|
95
98
|
|
96
99
|
def scope_by_group_clause
|
97
|
-
|
100
|
+
@scope = scope.group(group_clause)
|
98
101
|
end
|
99
102
|
|
100
103
|
def scope_by_joins
|
101
|
-
|
104
|
+
@scope = scope.joins(associations.join_values)
|
102
105
|
end
|
103
106
|
|
104
107
|
def scope_by_custom_joins
|
105
|
-
|
108
|
+
@scope = scope.joins(custom_joins) if custom_joins.any?
|
106
109
|
end
|
107
110
|
|
108
111
|
def scope_by_order
|
109
|
-
|
112
|
+
@scope = scope.order('NULL') if source.type == 'mysql'
|
113
|
+
end
|
114
|
+
|
115
|
+
def source
|
116
|
+
report.source
|
110
117
|
end
|
111
118
|
|
112
119
|
def method_missing(*args, &block)
|
@@ -7,8 +7,8 @@ module ThinkingSphinx
|
|
7
7
|
:groupings, :polymorphs
|
8
8
|
|
9
9
|
OPTIONS = [:name, :offset, :delta_processor, :delta?, :delta_options,
|
10
|
-
:disable_range?, :group_concat_max_len, :utf8?, :position,
|
11
|
-
:minimal_group_by
|
10
|
+
:disable_range?, :group_concat_max_len, :utf8?, :position,
|
11
|
+
:minimal_group_by?, :big_document_ids]
|
12
12
|
|
13
13
|
def initialize(model, options = {})
|
14
14
|
@model = model
|
@@ -91,7 +91,7 @@ class ThinkingSphinx::Configuration < Riddle::Configuration
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def render_to_file
|
94
|
-
FileUtils.mkdir_p searchd.binlog_path
|
94
|
+
FileUtils.mkdir_p searchd.binlog_path unless searchd.binlog_path.blank?
|
95
95
|
|
96
96
|
open(configuration_file, 'w') { |file| file.write render }
|
97
97
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module ThinkingSphinx::Connection
|
2
|
+
MAXIMUM_RETRIES = 3
|
3
|
+
|
2
4
|
def self.new
|
3
5
|
configuration = ThinkingSphinx::Configuration.instance
|
4
6
|
# If you use localhost, MySQL insists on a socket connection, but Sphinx
|
@@ -37,13 +39,13 @@ module ThinkingSphinx::Connection
|
|
37
39
|
yield connection
|
38
40
|
rescue ThinkingSphinx::QueryExecutionError, connection.base_error => error
|
39
41
|
original = ThinkingSphinx::SphinxError.new_from_mysql error
|
40
|
-
|
42
|
+
retries += MAXIMUM_RETRIES if original.is_a?(ThinkingSphinx::QueryError)
|
41
43
|
raise Innertube::Pool::BadResource
|
42
44
|
end
|
43
45
|
end
|
44
46
|
rescue Innertube::Pool::BadResource
|
45
47
|
retries += 1
|
46
|
-
raise original unless retries <
|
48
|
+
raise original unless retries < MAXIMUM_RETRIES
|
47
49
|
|
48
50
|
ActiveSupport::Notifications.instrument(
|
49
51
|
"message.thinking_sphinx", :message => "Retrying query \"#{original.statement}\" after error: #{original.message}"
|
@@ -3,18 +3,8 @@ class ThinkingSphinx::Controller < Riddle::Controller
|
|
3
3
|
options = indices.extract_options!
|
4
4
|
indices << '--all' if indices.empty?
|
5
5
|
|
6
|
-
indices
|
7
|
-
|
8
|
-
|
9
|
-
indices.each { |index| FileUtils.touch guard_file(index) }
|
10
|
-
super(*(indices + [options]))
|
11
|
-
indices.each { |index| FileUtils.rm guard_file(index) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def guard_file(index)
|
15
|
-
File.join(
|
16
|
-
ThinkingSphinx::Configuration.instance.indices_location,
|
17
|
-
"ts-#{index}.tmp"
|
18
|
-
)
|
6
|
+
ThinkingSphinx::Guard::Files.call(indices) do |names|
|
7
|
+
super(*(names + [options]))
|
8
|
+
end
|
19
9
|
end
|
20
10
|
end
|
@@ -3,7 +3,7 @@ module ThinkingSphinx::Core::Index
|
|
3
3
|
include ThinkingSphinx::Core::Settings
|
4
4
|
|
5
5
|
included do
|
6
|
-
attr_reader :reference, :offset
|
6
|
+
attr_reader :reference, :offset
|
7
7
|
attr_writer :definition_block
|
8
8
|
end
|
9
9
|
|
@@ -27,7 +27,7 @@ module ThinkingSphinx::Core::Index
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def document_id_for_key(key)
|
30
|
-
|
30
|
+
key * config.indices.count + offset
|
31
31
|
end
|
32
32
|
|
33
33
|
def interpret_definition!
|
@@ -43,6 +43,11 @@ module ThinkingSphinx::Core::Index
|
|
43
43
|
@model ||= reference.to_s.camelize.constantize
|
44
44
|
end
|
45
45
|
|
46
|
+
def options
|
47
|
+
interpret_definition!
|
48
|
+
@options
|
49
|
+
end
|
50
|
+
|
46
51
|
def render
|
47
52
|
pre_render
|
48
53
|
set_path
|
@@ -71,11 +76,16 @@ module ThinkingSphinx::Core::Index
|
|
71
76
|
'core'
|
72
77
|
end
|
73
78
|
|
79
|
+
def path_prefix
|
80
|
+
options[:path] || config.indices_location
|
81
|
+
end
|
82
|
+
|
74
83
|
def pre_render
|
75
84
|
interpret_definition!
|
76
85
|
end
|
77
86
|
|
78
87
|
def set_path
|
79
|
-
|
88
|
+
FileUtils.mkdir_p path_prefix
|
89
|
+
@path = File.join path_prefix, name
|
80
90
|
end
|
81
91
|
end
|