hawkerb-thinking-sphinx 1.3.15 → 1.3.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +18 -0
- data/VERSION +1 -1
- data/lib/thinking_sphinx/configuration.rb +26 -8
- data/lib/thinking_sphinx/search.rb +2 -8
- metadata +2 -2
data/README.textile
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
h1. Slightly modified version of Thinking Sphinx
|
2
2
|
|
3
|
+
h2. Performance improvements
|
4
|
+
|
5
|
+
This version uses MySQL ORDER BY FIELD(id,..) instruction to sort results returned by sphinx without using Ruby. It also means, that it will be incompatible with DBMS not supporting FIELD function.
|
6
|
+
|
3
7
|
h2. Removed automated includes
|
4
8
|
|
5
9
|
I this version, all of your models which use TS must manually include ThinkingSphinx modules. Example:
|
@@ -20,6 +24,20 @@ end
|
|
20
24
|
|
21
25
|
Because of that, it is a lot easier to override default sphinx methods.
|
22
26
|
|
27
|
+
h2. Default behaviour in tests
|
28
|
+
|
29
|
+
One of the reason to create this fork is to ensure that Thinking Sphinx will behave in same way on both production and test enviroment.
|
30
|
+
|
31
|
+
h2. Extended overrides in sphinx.yml
|
32
|
+
|
33
|
+
In sphinx.yml you can use:
|
34
|
+
|
35
|
+
development:
|
36
|
+
place_delta_0:
|
37
|
+
sql_query_pre: [ 'SET NAMES utf8' ]
|
38
|
+
|
39
|
+
to add an option which is specific only to single section of sphinx configuration file.
|
40
|
+
|
23
41
|
h1. Thinking Sphinx
|
24
42
|
|
25
43
|
h2. Usage
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.16
|
@@ -67,7 +67,7 @@ module ThinkingSphinx
|
|
67
67
|
attr_accessor :searchd_file_path, :allow_star, :database_yml_file,
|
68
68
|
:app_root, :model_directories, :delayed_job_priority
|
69
69
|
|
70
|
-
attr_accessor :source_options, :index_options
|
70
|
+
attr_accessor :source_options, :index_options, :section_options
|
71
71
|
|
72
72
|
attr_reader :environment, :configuration, :controller
|
73
73
|
|
@@ -110,6 +110,7 @@ module ThinkingSphinx
|
|
110
110
|
self.delayed_job_priority = 0
|
111
111
|
|
112
112
|
self.source_options = {}
|
113
|
+
self.section_options = {}
|
113
114
|
self.index_options = {
|
114
115
|
:charset_type => "utf-8"
|
115
116
|
}
|
@@ -141,7 +142,7 @@ module ThinkingSphinx
|
|
141
142
|
ThinkingSphinx.context.indexed_models.each do |model|
|
142
143
|
model = model.constantize
|
143
144
|
model.define_indexes
|
144
|
-
@configuration.indexes.concat model.to_riddle
|
145
|
+
@configuration.indexes.concat merge_with_section_options!(model.to_riddle)
|
145
146
|
end
|
146
147
|
|
147
148
|
open(file_path, "w") do |file|
|
@@ -254,12 +255,16 @@ module ThinkingSphinx
|
|
254
255
|
|
255
256
|
conf.each do |key,value|
|
256
257
|
self.send("#{key}=", value) if self.respond_to?("#{key}=")
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
258
|
+
|
259
|
+
if value.is_a?(Hash)
|
260
|
+
self.section_options[key] = value
|
261
|
+
else
|
262
|
+
set_sphinx_setting self.source_options, key, value, SourceOptions
|
263
|
+
set_sphinx_setting self.index_options, key, value, IndexOptions
|
264
|
+
set_sphinx_setting self.index_options, key, value, CustomOptions
|
265
|
+
set_sphinx_setting @configuration.searchd, key, value
|
266
|
+
set_sphinx_setting @configuration.indexer, key, value
|
267
|
+
end
|
263
268
|
end unless conf.nil?
|
264
269
|
|
265
270
|
self.bin_path += '/' unless self.bin_path.blank?
|
@@ -278,5 +283,18 @@ module ThinkingSphinx
|
|
278
283
|
send("#{key}=", value) if self.respond_to?("#{key}")
|
279
284
|
end
|
280
285
|
end
|
286
|
+
|
287
|
+
def merge_with_section_options!(indexes)
|
288
|
+
indexes.each do |index|
|
289
|
+
if nested_values = section_options[index.name]
|
290
|
+
nested_values.each_pair {|key, val| index.send(:"#{key}=",val) }
|
291
|
+
end
|
292
|
+
|
293
|
+
if index.respond_to?(:sources)
|
294
|
+
merge_with_section_options!(index.sources)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
indexes
|
298
|
+
end
|
281
299
|
end
|
282
300
|
end
|
@@ -669,7 +669,7 @@ MSG
|
|
669
669
|
:conditions => {klass.primary_key_for_sphinx.to_sym => ids},
|
670
670
|
:include => (options[:include] || index_options[:include]),
|
671
671
|
:select => (options[:select] || index_options[:select]),
|
672
|
-
:order => (options[:sql_order] || index_options[:sql_order])
|
672
|
+
:order => (options[:sql_order] || index_options[:sql_order] || "FIELD(id, #{ids.join(',') })")
|
673
673
|
) : []
|
674
674
|
|
675
675
|
# Raise an exception if we find records in Sphinx but not in the DB, so
|
@@ -682,13 +682,7 @@ MSG
|
|
682
682
|
|
683
683
|
# if the user has specified an SQL order, return the collection
|
684
684
|
# without rearranging it into the Sphinx order
|
685
|
-
return instances
|
686
|
-
|
687
|
-
ids.collect { |obj_id|
|
688
|
-
instances.detect do |obj|
|
689
|
-
obj.primary_key_for_sphinx == obj_id
|
690
|
-
end
|
691
|
-
}
|
685
|
+
return instances
|
692
686
|
end
|
693
687
|
|
694
688
|
# Group results by class and call #find(:all) once for each group to reduce
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hawkerb-thinking-sphinx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-01-
|
13
|
+
date: 2010-01-20 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|