thinking-sphinx 1.5.0 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/README.textile +15 -48
  2. data/VERSION +1 -0
  3. data/features/attribute_transformation.feature +7 -7
  4. data/features/attribute_updates.feature +16 -18
  5. data/features/deleting_instances.feature +13 -16
  6. data/features/excerpts.feature +0 -8
  7. data/features/facets.feature +19 -25
  8. data/features/handling_edits.feature +20 -25
  9. data/features/searching_across_models.feature +1 -1
  10. data/features/searching_by_index.feature +5 -6
  11. data/features/searching_by_model.feature +29 -29
  12. data/features/sphinx_scopes.feature +0 -26
  13. data/features/step_definitions/common_steps.rb +6 -18
  14. data/features/step_definitions/scope_steps.rb +0 -4
  15. data/features/step_definitions/search_steps.rb +4 -9
  16. data/features/support/env.rb +10 -3
  17. data/features/thinking_sphinx/db/fixtures/alphas.rb +10 -8
  18. data/features/thinking_sphinx/db/fixtures/cats.rb +1 -1
  19. data/features/thinking_sphinx/db/fixtures/dogs.rb +1 -1
  20. data/features/thinking_sphinx/db/fixtures/foxes.rb +1 -1
  21. data/features/thinking_sphinx/db/fixtures/people.rb +1 -1
  22. data/features/thinking_sphinx/db/fixtures/posts.rb +1 -5
  23. data/features/thinking_sphinx/db/migrations/create_posts.rb +0 -1
  24. data/features/thinking_sphinx/models/alpha.rb +0 -1
  25. data/features/thinking_sphinx/models/beta.rb +0 -5
  26. data/features/thinking_sphinx/models/developer.rb +1 -6
  27. data/features/thinking_sphinx/models/music.rb +1 -3
  28. data/features/thinking_sphinx/models/person.rb +1 -2
  29. data/features/thinking_sphinx/models/post.rb +0 -1
  30. data/lib/cucumber/thinking_sphinx/external_world.rb +4 -8
  31. data/lib/cucumber/thinking_sphinx/internal_world.rb +27 -36
  32. data/lib/thinking_sphinx.rb +60 -132
  33. data/lib/thinking_sphinx/active_record.rb +98 -124
  34. data/lib/thinking_sphinx/active_record/attribute_updates.rb +13 -17
  35. data/lib/thinking_sphinx/active_record/delta.rb +15 -21
  36. data/lib/thinking_sphinx/active_record/has_many_association.rb +23 -16
  37. data/lib/thinking_sphinx/active_record/scopes.rb +0 -18
  38. data/lib/thinking_sphinx/adapters/abstract_adapter.rb +15 -63
  39. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +0 -4
  40. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +24 -65
  41. data/lib/thinking_sphinx/association.rb +11 -36
  42. data/lib/thinking_sphinx/attribute.rb +85 -92
  43. data/lib/thinking_sphinx/auto_version.rb +3 -21
  44. data/lib/thinking_sphinx/class_facet.rb +3 -8
  45. data/lib/thinking_sphinx/configuration.rb +58 -114
  46. data/lib/thinking_sphinx/context.rb +20 -22
  47. data/lib/thinking_sphinx/core/array.rb +13 -0
  48. data/lib/thinking_sphinx/deltas.rb +0 -2
  49. data/lib/thinking_sphinx/deltas/default_delta.rb +22 -18
  50. data/lib/thinking_sphinx/deploy/capistrano.rb +31 -30
  51. data/lib/thinking_sphinx/excerpter.rb +1 -2
  52. data/lib/thinking_sphinx/facet.rb +35 -45
  53. data/lib/thinking_sphinx/facet_search.rb +24 -58
  54. data/lib/thinking_sphinx/field.rb +0 -18
  55. data/lib/thinking_sphinx/index.rb +36 -38
  56. data/lib/thinking_sphinx/index/builder.rb +59 -74
  57. data/lib/thinking_sphinx/property.rb +45 -66
  58. data/lib/thinking_sphinx/railtie.rb +35 -0
  59. data/lib/thinking_sphinx/search.rb +250 -506
  60. data/lib/thinking_sphinx/source.rb +31 -50
  61. data/lib/thinking_sphinx/source/internal_properties.rb +3 -8
  62. data/lib/thinking_sphinx/source/sql.rb +31 -71
  63. data/lib/thinking_sphinx/tasks.rb +27 -48
  64. data/spec/thinking_sphinx/active_record/delta_spec.rb +41 -36
  65. data/spec/thinking_sphinx/active_record/has_many_association_spec.rb +0 -96
  66. data/spec/thinking_sphinx/active_record/scopes_spec.rb +29 -29
  67. data/spec/thinking_sphinx/active_record_spec.rb +169 -140
  68. data/spec/thinking_sphinx/association_spec.rb +2 -20
  69. data/spec/thinking_sphinx/attribute_spec.rb +97 -101
  70. data/spec/thinking_sphinx/auto_version_spec.rb +11 -75
  71. data/spec/thinking_sphinx/configuration_spec.rb +62 -63
  72. data/spec/thinking_sphinx/context_spec.rb +66 -66
  73. data/spec/thinking_sphinx/facet_search_spec.rb +99 -99
  74. data/spec/thinking_sphinx/facet_spec.rb +4 -30
  75. data/spec/thinking_sphinx/field_spec.rb +3 -17
  76. data/spec/thinking_sphinx/index/builder_spec.rb +132 -169
  77. data/spec/thinking_sphinx/index_spec.rb +39 -45
  78. data/spec/thinking_sphinx/search_methods_spec.rb +33 -37
  79. data/spec/thinking_sphinx/search_spec.rb +269 -491
  80. data/spec/thinking_sphinx/source_spec.rb +48 -62
  81. data/spec/thinking_sphinx_spec.rb +49 -49
  82. data/tasks/distribution.rb +46 -0
  83. data/tasks/testing.rb +74 -0
  84. metadata +123 -199
  85. data/features/field_sorting.feature +0 -18
  86. data/features/thinking_sphinx/db/.gitignore +0 -1
  87. data/features/thinking_sphinx/db/fixtures/post_keywords.txt +0 -1
  88. data/features/thinking_sphinx/models/andrew.rb +0 -17
  89. data/lib/thinking-sphinx.rb +0 -1
  90. data/lib/thinking_sphinx/active_record/has_many_association_with_scopes.rb +0 -21
  91. data/lib/thinking_sphinx/bundled_search.rb +0 -40
  92. data/lib/thinking_sphinx/connection.rb +0 -71
  93. data/lib/thinking_sphinx/deltas/delete_job.rb +0 -16
  94. data/lib/thinking_sphinx/deltas/index_job.rb +0 -17
  95. data/lib/thinking_sphinx/rails_additions.rb +0 -181
  96. data/spec/fixtures/data.sql +0 -32
  97. data/spec/fixtures/database.yml.default +0 -3
  98. data/spec/fixtures/models.rb +0 -161
  99. data/spec/fixtures/structure.sql +0 -146
  100. data/spec/spec_helper.rb +0 -54
  101. data/spec/sphinx_helper.rb +0 -67
  102. data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +0 -163
  103. data/spec/thinking_sphinx/connection_spec.rb +0 -77
  104. data/spec/thinking_sphinx/rails_additions_spec.rb +0 -203
@@ -5,11 +5,11 @@ module ThinkingSphinx
5
5
  class Source
6
6
  include ThinkingSphinx::Source::InternalProperties
7
7
  include ThinkingSphinx::Source::SQL
8
-
8
+
9
9
  attr_accessor :model, :fields, :attributes, :joins, :conditions, :groupings,
10
10
  :options
11
11
  attr_reader :base, :index, :database_configuration
12
-
12
+
13
13
  def initialize(index, options = {})
14
14
  @index = index
15
15
  @model = index.model
@@ -22,123 +22,104 @@ module ThinkingSphinx
22
22
  @associations = {}
23
23
  @database_configuration = @model.connection.
24
24
  instance_variable_get(:@config).clone
25
-
25
+
26
26
  @base = ::ActiveRecord::Associations::ClassMethods::JoinDependency.new(
27
27
  @model, [], nil
28
28
  )
29
-
29
+
30
30
  unless @model.descends_from_active_record?
31
31
  stored_class = @model.store_full_sti_class ? @model.name : @model.name.demodulize
32
32
  @conditions << "#{@model.quoted_table_name}.#{quote_column(@model.inheritance_column)} = '#{stored_class}'"
33
33
  end
34
-
34
+
35
35
  add_internal_attributes_and_facets
36
36
  end
37
-
37
+
38
38
  def name
39
39
  index.name
40
40
  end
41
-
41
+
42
42
  def to_riddle_for_core(offset, position)
43
43
  source = Riddle::Configuration::SQLSource.new(
44
44
  "#{index.core_name}_#{position}", adapter.sphinx_identifier
45
45
  )
46
-
46
+
47
47
  set_source_database_settings source
48
- set_source_fields source
49
48
  set_source_attributes source, offset
50
49
  set_source_settings source
51
50
  set_source_sql source, offset
52
-
51
+
53
52
  source
54
53
  end
55
-
54
+
56
55
  def to_riddle_for_delta(offset, position)
57
56
  source = Riddle::Configuration::SQLSource.new(
58
57
  "#{index.delta_name}_#{position}", adapter.sphinx_identifier
59
58
  )
60
59
  source.parent = "#{index.core_name}_#{position}"
61
-
60
+
62
61
  set_source_database_settings source
63
- set_source_fields source
64
62
  set_source_attributes source, offset, true
65
63
  set_source_settings source
66
64
  set_source_sql source, offset, true
67
-
65
+
68
66
  source
69
67
  end
70
-
68
+
71
69
  def delta?
72
70
  !@index.delta_object.nil?
73
71
  end
74
-
72
+
75
73
  # Gets the association stack for a specific key.
76
- #
74
+ #
77
75
  def association(key)
78
76
  @associations[key] ||= Association.children(@model, key)
79
77
  end
80
-
78
+
81
79
  private
82
-
80
+
83
81
  def adapter
84
82
  @adapter ||= @model.sphinx_database_adapter
85
83
  end
86
-
87
- def available_attributes
88
- attributes.select { |attrib| attrib.available? }
89
- end
90
-
84
+
91
85
  def set_source_database_settings(source)
92
86
  config = @database_configuration
93
-
87
+
94
88
  source.sql_host = config[:host] || "localhost"
95
- source.sql_user = config[:username] || config[:user] || ENV['USER']
89
+ source.sql_user = config[:username] || config[:user] || 'root'
96
90
  source.sql_pass = (config[:password].to_s || "").gsub('#', '\#')
97
91
  source.sql_db = config[:database]
98
92
  source.sql_port = config[:port]
99
93
  source.sql_sock = config[:socket]
100
-
101
- # MySQL SSL support
102
- source.mysql_ssl_ca = config[:sslca] if config[:sslca]
103
- source.mysql_ssl_cert = config[:sslcert] if config[:sslcert]
104
- source.mysql_ssl_key = config[:sslkey] if config[:sslkey]
105
94
  end
106
-
107
- def set_source_fields(source)
108
- fields.each do |field|
109
- source.sql_file_field << field.unique_name if field.file?
110
- source.sql_field_string << field.unique_name if field.with_attribute?
111
- source.sql_field_str2wordcount << field.unique_name if field.with_wordcount?
112
- end
113
- end
114
-
95
+
115
96
  def set_source_attributes(source, offset, delta = false)
116
- available_attributes.each do |attrib|
97
+ attributes.each do |attrib|
117
98
  source.send(attrib.type_to_config) << attrib.config_value(offset, delta)
118
99
  end
119
100
  end
120
-
101
+
121
102
  def set_source_sql(source, offset, delta = false)
122
103
  source.sql_query = to_sql(:offset => offset, :delta => delta).gsub(/\n/, ' ')
123
104
  source.sql_query_range = to_sql_query_range(:delta => delta)
124
105
  source.sql_query_info = to_sql_query_info(offset)
125
-
106
+
126
107
  source.sql_query_pre += send(!delta ? :sql_query_pre_for_core : :sql_query_pre_for_delta)
127
-
108
+
128
109
  if @index.local_options[:group_concat_max_len]
129
110
  source.sql_query_pre << "SET SESSION group_concat_max_len = #{@index.local_options[:group_concat_max_len]}"
130
111
  end
131
-
112
+
132
113
  source.sql_query_pre += [adapter.utf8_query_pre].compact if utf8?
133
114
  source.sql_query_pre << adapter.utc_query_pre
134
115
  end
135
-
116
+
136
117
  def set_source_settings(source)
137
118
  config = ThinkingSphinx::Configuration.instance
138
119
  config.source_options.each do |key, value|
139
120
  source.send("#{key}=".to_sym, value)
140
121
  end
141
-
122
+
142
123
  source_options = ThinkingSphinx::Configuration::SourceOptions
143
124
  @options.each do |key, value|
144
125
  if source_options.include?(key.to_s) && !value.nil?
@@ -146,11 +127,11 @@ module ThinkingSphinx
146
127
  end
147
128
  end
148
129
  end
149
-
130
+
150
131
  # Returns all associations used amongst all the fields and attributes.
151
132
  # This includes all associations between the model and what the actual
152
133
  # columns are from.
153
- #
134
+ #
154
135
  def all_associations
155
136
  @all_associations ||= (
156
137
  # field associations
@@ -170,7 +151,7 @@ module ThinkingSphinx
170
151
  assoc.ancestors
171
152
  }.flatten.uniq
172
153
  end
173
-
154
+
174
155
  def utf8?
175
156
  @index.options[:charset_type] =~ /utf-8|zh_cn.utf-8/
176
157
  end
@@ -4,15 +4,10 @@ module ThinkingSphinx
4
4
  def add_internal_attributes_and_facets
5
5
  add_internal_attribute :sphinx_internal_id, nil,
6
6
  @model.primary_key_for_sphinx.to_sym
7
- add_internal_attribute :sphinx_deleted, :integer, "0"
8
7
  add_internal_attribute :class_crc, :integer, crc_column, true
9
-
10
- unless Riddle.loaded_version.to_i < 2
11
- add_internal_attribute :sphinx_internal_class, :string, internal_class_column, true
12
- add_internal_facet :sphinx_internal_class
13
- else
14
- add_internal_facet :class_crc
15
- end
8
+ add_internal_attribute :sphinx_deleted, :integer, "0"
9
+
10
+ add_internal_facet :class_crc
16
11
  end
17
12
 
18
13
  def add_internal_attribute(name, type, contents, facet = false)
@@ -3,37 +3,39 @@ module ThinkingSphinx
3
3
  module SQL
4
4
  # Generates the big SQL statement to get the data back for all the fields
5
5
  # and attributes, using all the relevant association joins. If you want
6
- # the version filtered for delta values, send through :delta => true in the
7
- # options. Won't do much though if the index isn't set up to support a
6
+ # the version filtered for delta values, send through :delta => true in
7
+ # the options. Won't do much though if the index isn't set up to support a
8
8
  # delta sibling.
9
- #
9
+ #
10
10
  # Examples:
11
- #
11
+ #
12
12
  # source.to_sql
13
13
  # source.to_sql(:delta => true)
14
14
  #
15
15
  def to_sql(options={})
16
- sql = "SELECT "
17
- sql += "SQL_NO_CACHE " if adapter.sphinx_identifier == "mysql"
18
- sql += <<-SQL
19
- #{ sql_select_clause options[:offset] }
20
- FROM #{ @model.quoted_table_name }
21
- #{ all_associations.collect { |assoc| assoc.to_sql }.join(' ') }
22
- #{ sql_where_clause(options) }
23
- GROUP BY #{ sql_group_clause }
24
- SQL
25
-
26
- sql += " ORDER BY NULL" if adapter.sphinx_identifier == "mysql"
27
- sql
16
+ relation = @model.unscoped
17
+ pre_select = 'SQL_NO_CACHE ' if adapter.sphinx_identifier == "mysql"
18
+ relation = relation.select(
19
+ pre_select.to_s + sql_select_clause(options[:offset])
20
+ )
21
+
22
+ all_associations.each do |assoc|
23
+ relation = relation.joins(assoc.join.with_join_class(Arel::OuterJoin))
24
+ end
25
+
26
+ relation = relation.where(sql_where_clause(options))
27
+ relation = relation.group(sql_group_clause)
28
+ relation = relation.order('NULL') if adapter.sphinx_identifier == "mysql"
29
+ relation.to_sql
28
30
  end
29
31
 
30
32
  # Simple helper method for the query range SQL - which is a statement that
31
33
  # returns minimum and maximum id values. These can be filtered by delta -
32
34
  # so pass in :delta => true to get the delta version of the SQL.
33
- #
35
+ #
34
36
  def to_sql_query_range(options={})
35
37
  return nil if @index.options[:disable_range]
36
-
38
+
37
39
  min_statement = adapter.convert_nulls(
38
40
  "MIN(#{quote_column(@model.primary_key_for_sphinx)})", 1
39
41
  )
@@ -52,17 +54,17 @@ GROUP BY #{ sql_group_clause }
52
54
 
53
55
  # Simple helper method for the query info SQL - which is a statement that
54
56
  # returns the single row for a corresponding id.
55
- #
57
+ #
56
58
  def to_sql_query_info(offset)
57
59
  "SELECT * FROM #{@model.quoted_table_name} WHERE " +
58
60
  "#{quote_column(@model.primary_key_for_sphinx)} = (($id - #{offset}) / #{ThinkingSphinx.context.indexed_models.size})"
59
61
  end
60
62
 
61
63
  def sql_select_clause(offset)
62
- unique_id_expr = ThinkingSphinx.unique_id_expression(adapter, offset)
64
+ unique_id_expr = ThinkingSphinx.unique_id_expression(offset)
63
65
 
64
66
  (
65
- ["#{@model.quoted_table_name}.#{quote_column(@model.primary_key_for_sphinx)} #{unique_id_expr} AS #{quote_column(@model.primary_key_for_sphinx)} "] +
67
+ ["#{@model.quoted_table_name}.#{quote_column(@model.primary_key_for_sphinx)} #{unique_id_expr} AS #{quote_column(@model.primary_key_for_sphinx)} "] +
66
68
  @fields.collect { |field| field.to_select_sql } +
67
69
  @attributes.collect { |attribute| attribute.to_select_sql }
68
70
  ).compact.join(", ")
@@ -80,7 +82,7 @@ GROUP BY #{ sql_group_clause }
80
82
  end
81
83
 
82
84
  logic += (@conditions || [])
83
- logic.empty? ? "" : "WHERE #{logic.join(' AND ')}"
85
+ logic.join(' AND ')
84
86
  end
85
87
 
86
88
  def sql_group_clause
@@ -90,7 +92,7 @@ GROUP BY #{ sql_group_clause }
90
92
  end
91
93
 
92
94
  (
93
- ["#{@model.quoted_table_name}.#{quote_column(@model.primary_key_for_sphinx)}"] +
95
+ ["#{@model.quoted_table_name}.#{quote_column(@model.primary_key_for_sphinx)}"] +
94
96
  @fields.collect { |field| field.to_group_sql }.compact +
95
97
  @attributes.collect { |attribute| attribute.to_group_sql }.compact +
96
98
  @groupings + internal_groupings
@@ -116,57 +118,15 @@ GROUP BY #{ sql_group_clause }
116
118
  def crc_column
117
119
  if @model.table_exists? &&
118
120
  @model.column_names.include?(@model.inheritance_column)
119
-
120
- types = types_to_crcs
121
- return @model.to_crc32.to_s if types.empty?
122
-
123
- adapter.case(adapter.convert_nulls(
124
- adapter.quote_with_table(@model.inheritance_column), @model.name),
125
- types, @model.to_crc32)
121
+
122
+ adapter.cast_to_unsigned(adapter.convert_nulls(
123
+ adapter.crc(adapter.quote_with_table(@model.inheritance_column), true),
124
+ @model.to_crc32
125
+ ))
126
126
  else
127
127
  @model.to_crc32.to_s
128
128
  end
129
129
  end
130
-
131
- def internal_class_column
132
- quoted_name = "'#{@model.name}'"
133
-
134
- if @model.table_exists? &&
135
- @model.column_names.include?(@model.inheritance_column)
136
-
137
- types = types_to_hash
138
- return quoted_name if types.empty?
139
-
140
- adapter.case(adapter.convert_nulls(
141
- adapter.quote_with_table(@model.inheritance_column), @model.name),
142
- types, quoted_name)
143
- else
144
- quoted_name
145
- end
146
- end
147
-
148
- def type_values
149
- return @model.sphinx_types unless @model.sphinx_types.nil?
150
-
151
- @model.connection.select_values <<-SQL
152
- SELECT DISTINCT #{@model.inheritance_column}
153
- FROM #{@model.table_name}
154
- SQL
155
- end
156
-
157
- def types_to_crcs
158
- type_values.compact.inject({}) { |hash, type|
159
- hash[type] = type.to_crc32
160
- hash
161
- }
162
- end
163
-
164
- def types_to_hash
165
- type_values.compact.inject({}) { |hash, type|
166
- hash[type] = "'#{type}'"
167
- hash
168
- }
169
- end
170
130
  end
171
131
  end
172
- end
132
+ end
@@ -1,56 +1,44 @@
1
1
  require 'fileutils'
2
- require 'timeout'
3
2
 
4
3
  namespace :thinking_sphinx do
5
4
  task :app_env do
6
- if defined?(RAILS_ROOT)
5
+ if defined?(Rails)
7
6
  Rake::Task[:environment].invoke
8
- if defined?(Rails.configuration)
9
- Rails.configuration.cache_classes = false
10
- else
11
- Rails::Initializer.run { |config| config.cache_classes = false }
12
- end
13
- elsif defined?(Merb)
14
- Rake::Task[:merb_env].invoke
15
- elsif defined?(Sinatra)
16
- Sinatra::Application.environment = ENV['RACK_ENV']
7
+ Rails.configuration.cache_classes = false
17
8
  end
9
+
10
+ Rake::Task[:merb_env].invoke if defined?(Merb)
18
11
  end
19
-
12
+
13
+ desc "Output the current Thinking Sphinx version"
14
+ task :version => :app_env do
15
+ puts "Thinking Sphinx v" + ThinkingSphinx.version
16
+ end
17
+
20
18
  desc "Stop if running, then start a Sphinx searchd daemon using Thinking Sphinx's settings"
21
19
  task :running_start => :app_env do
22
20
  Rake::Task["thinking_sphinx:stop"].invoke if sphinx_running?
23
21
  Rake::Task["thinking_sphinx:start"].invoke
24
22
  end
25
-
23
+
26
24
  desc "Start a Sphinx searchd daemon using Thinking Sphinx's settings"
27
25
  task :start => :app_env do
28
26
  config = ThinkingSphinx::Configuration.instance
29
-
27
+
30
28
  FileUtils.mkdir_p config.searchd_file_path
31
29
  raise RuntimeError, "searchd is already running." if sphinx_running?
32
-
30
+
33
31
  Dir["#{config.searchd_file_path}/*.spl"].each { |file| File.delete(file) }
34
-
35
- if ENV["NODETACH"] == "true"
36
- unless pid = fork
37
- config.controller.start(:nodetach => true)
38
- end
39
- Signal.trap('TERM') { Process.kill(:QUIT, pid) }
40
- Signal.trap('INT') { Process.kill(:QUIT, pid) }
41
- Process.wait(pid)
32
+
33
+ config.controller.start
34
+
35
+ if sphinx_running?
36
+ puts "Started successfully (pid #{sphinx_pid})."
42
37
  else
43
- config.controller.start
44
-
45
- if sphinx_running?
46
- puts "Started successfully (pid #{sphinx_pid})."
47
- else
48
- puts "Failed to start searchd daemon. Check #{config.searchd_log_file}"
49
- puts "Be sure to run thinking_sphinx:index before thinking_sphinx:start"
50
- end
38
+ puts "Failed to start searchd daemon. Check #{config.searchd_log_file}"
51
39
  end
52
40
  end
53
-
41
+
54
42
  desc "Stop Sphinx using Thinking Sphinx's settings"
55
43
  task :stop => :app_env do
56
44
  unless sphinx_running?
@@ -59,26 +47,20 @@ namespace :thinking_sphinx do
59
47
  config = ThinkingSphinx::Configuration.instance
60
48
  pid = sphinx_pid
61
49
  config.controller.stop
62
-
63
- # Ensure searchd is stopped, but don't try too hard
64
- Timeout.timeout(config.stop_timeout) do
65
- sleep(1) until config.controller.stop
66
- end
67
-
68
50
  puts "Stopped search daemon (pid #{pid})."
69
51
  end
70
52
  end
71
-
53
+
72
54
  desc "Restart Sphinx"
73
55
  task :restart => [:app_env, :stop, :start]
74
-
56
+
75
57
  desc "Generate the Sphinx configuration file using Thinking Sphinx's settings"
76
58
  task :configure => :app_env do
77
59
  config = ThinkingSphinx::Configuration.instance
78
60
  puts "Generating Configuration to #{config.config_file}"
79
61
  config.build
80
62
  end
81
-
63
+
82
64
  desc "Index data for Sphinx using Thinking Sphinx's settings"
83
65
  task :index => :app_env do
84
66
  config = ThinkingSphinx::Configuration.instance
@@ -86,21 +68,18 @@ namespace :thinking_sphinx do
86
68
  puts "Generating Configuration to #{config.config_file}"
87
69
  config.build
88
70
  end
89
-
71
+
90
72
  FileUtils.mkdir_p config.searchd_file_path
91
- ThinkingSphinx.before_index_hooks.each { |hook| hook.call }
92
73
  config.controller.index :verbose => true
93
74
  end
94
-
75
+
95
76
  desc "Reindex Sphinx without regenerating the configuration file"
96
77
  task :reindex => :app_env do
97
78
  config = ThinkingSphinx::Configuration.instance
98
79
  FileUtils.mkdir_p config.searchd_file_path
99
- output = config.controller.index
100
- puts output
101
- config.touch_reindex_file(output)
80
+ puts config.controller.index
102
81
  end
103
-
82
+
104
83
  desc "Stop Sphinx (if it's running), rebuild the indexes, and start Sphinx"
105
84
  task :rebuild => :app_env do
106
85
  Rake::Task["thinking_sphinx:stop"].invoke if sphinx_running?