thinking-sphinx 2.0.14 → 2.1.0
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.
- data/HISTORY +17 -1
- data/features/attribute_updates.feature +15 -13
- data/features/deleting_instances.feature +16 -13
- data/features/handling_edits.feature +20 -17
- data/features/searching_by_index.feature +6 -5
- data/features/step_definitions/common_steps.rb +4 -0
- data/features/support/env.rb +0 -3
- data/lib/thinking_sphinx.rb +8 -1
- data/lib/thinking_sphinx/active_record.rb +3 -3
- data/lib/thinking_sphinx/active_record/attribute_updates.rb +5 -4
- data/lib/thinking_sphinx/adapters/abstract_adapter.rb +7 -0
- data/lib/thinking_sphinx/auto_version.rb +1 -1
- data/lib/thinking_sphinx/bundled_search.rb +6 -10
- data/lib/thinking_sphinx/configuration.rb +19 -33
- data/lib/thinking_sphinx/connection.rb +71 -0
- data/lib/thinking_sphinx/deltas.rb +2 -0
- data/lib/thinking_sphinx/deltas/default_delta.rb +14 -18
- data/lib/thinking_sphinx/deltas/delete_job.rb +16 -0
- data/lib/thinking_sphinx/deltas/index_job.rb +17 -0
- data/lib/thinking_sphinx/search.rb +26 -15
- data/lib/thinking_sphinx/tasks.rb +1 -5
- data/spec/spec_helper.rb +0 -3
- data/spec/thinking_sphinx/active_record/delta_spec.rb +6 -5
- data/spec/thinking_sphinx/active_record/scopes_spec.rb +2 -1
- data/spec/thinking_sphinx/active_record_spec.rb +2 -2
- data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +18 -0
- data/spec/thinking_sphinx/configuration_spec.rb +0 -68
- data/spec/thinking_sphinx/connection_spec.rb +77 -0
- data/spec/thinking_sphinx/facet_search_spec.rb +25 -25
- data/spec/thinking_sphinx/search_methods_spec.rb +34 -34
- data/spec/thinking_sphinx/search_spec.rb +4 -16
- metadata +197 -186
- data/lib/thinking_sphinx/version.rb +0 -3
data/HISTORY
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0 - May 7th 2013
|
2
|
+
* 1.5.0 changes.
|
3
|
+
|
4
|
+
2.0.14 - January 2nd 2013
|
2
5
|
* Fix model loading for Rails 3.2.9 when subdirectories exist (Kenn Ejima).
|
3
6
|
* Use BasicObject instead of BlankSlate when running on 1.9 (Steve Purcell).
|
4
7
|
* 1.4.14 changes.
|
@@ -69,6 +72,19 @@
|
|
69
72
|
* Rails 3 support.
|
70
73
|
* 1.4.0 changes.
|
71
74
|
|
75
|
+
1.5.0 - May 7th 2013
|
76
|
+
* Removed plugin support - Thinking Sphinx is now gem-only across all branches.
|
77
|
+
* ThinkingSphinx::Version and the thinking_sphinx:version task have been removed - it's a gem, it has a version number.
|
78
|
+
* Updating Riddle to 1.5.6 or newer.
|
79
|
+
* Requires ActiveRecord ~> 2.1 (earlier versions were considered unsupported a few releases ago).
|
80
|
+
* Allow custom Riddle controllers - useful for Flying Sphinx to take over management of Sphinx daemon/indexing actions.
|
81
|
+
* Rejigged delta support to be generic, with local job classes that provide a clean, simple interface for third-party libraries.
|
82
|
+
* Add hooks for anything that needs to happen before indexing (such as clearing out existing delta jobs).
|
83
|
+
* Connection pool for all Sphinx client communication, with new connections built if there's any connection-related (as opposed to syntax) issues.
|
84
|
+
* Multiple-field search conditions can be done with arrays of field names as keys in the :conditions hash (Alex Dowad).
|
85
|
+
* Removed named capture in regular expressions to maintain MRI 1.8 support (Michael Wintrant).
|
86
|
+
* Support new JDBC configuration style (Kyle Stevens).
|
87
|
+
|
72
88
|
1.4.14 - January 2nd 2013
|
73
89
|
* Allow sql_query_pre values to come through from config/sphinx.yml (George Ogata).
|
74
90
|
* ThinkingSphinx::Search#tap doesn't delegate through to the underlying array.
|
@@ -2,13 +2,13 @@ Feature: Update attributes directly to Sphinx
|
|
2
2
|
In order for updates to be more seamless
|
3
3
|
The plugin
|
4
4
|
Should update Sphinx's attributes where possible
|
5
|
-
|
5
|
+
|
6
6
|
Scenario: Updating attributes in Sphinx without delta indexes
|
7
7
|
Given Sphinx is running
|
8
8
|
And I am searching on alphas
|
9
9
|
When I filter by 3 on value
|
10
10
|
Then I should get 1 result
|
11
|
-
|
11
|
+
|
12
12
|
When I change the value of alpha four to 13
|
13
13
|
And I wait for Sphinx to catch up
|
14
14
|
And I filter by 13 on value
|
@@ -16,7 +16,7 @@ Feature: Update attributes directly to Sphinx
|
|
16
16
|
Then I should get 1 result
|
17
17
|
When I use index alternative_core
|
18
18
|
Then I should get 1 result
|
19
|
-
|
19
|
+
|
20
20
|
When I change the value of alpha four to 4
|
21
21
|
And I wait for Sphinx to catch up
|
22
22
|
And I filter by 13 on value
|
@@ -30,47 +30,49 @@ Feature: Update attributes directly to Sphinx
|
|
30
30
|
And I am searching on betas
|
31
31
|
When I filter by 8 on value
|
32
32
|
Then I should get 1 result
|
33
|
-
|
33
|
+
|
34
34
|
When I change the value of beta eight to 18
|
35
35
|
And I wait for Sphinx to catch up
|
36
36
|
And I filter by 18 on value
|
37
37
|
Then I should get 1 result
|
38
|
-
|
38
|
+
|
39
39
|
When I search for the document id of beta eight in the secondary_beta_delta index
|
40
40
|
Then it should not exist
|
41
|
-
|
41
|
+
|
42
42
|
Scenario: Updating attributes in a delta index
|
43
43
|
Given Sphinx is running
|
44
44
|
And I am searching on betas
|
45
|
-
|
45
|
+
|
46
46
|
When I change the name of beta nine to nineteen
|
47
47
|
And I change the value of beta nineteen to 19
|
48
48
|
And I wait for Sphinx to catch up
|
49
|
-
|
49
|
+
|
50
50
|
When I filter by 19 on value
|
51
51
|
And I use index secondary_beta_delta
|
52
|
+
And I clear the connection pool
|
52
53
|
Then I should get 1 result
|
53
|
-
|
54
|
+
|
54
55
|
Scenario: Updating attributes in a delta index with deltas disabled
|
55
56
|
Given Sphinx is running
|
56
57
|
And I am searching on betas
|
57
|
-
|
58
|
+
|
58
59
|
When I change the name of beta eleven to twentyone
|
59
60
|
And I disable delta updates
|
60
61
|
And I change the value of beta twentyone to 21
|
61
62
|
And I wait for Sphinx to catch up
|
62
|
-
|
63
|
+
And I clear the connection pool
|
64
|
+
|
63
65
|
When I filter by 21 on value
|
64
66
|
And I use index secondary_beta_delta
|
65
67
|
Then I should get 1 result
|
66
68
|
And I enable delta updates
|
67
|
-
|
69
|
+
|
68
70
|
Scenario: Updating boolean attribute in Sphinx
|
69
71
|
Given Sphinx is running
|
70
72
|
And I am searching on alphas
|
71
73
|
When I filter by active alphas
|
72
74
|
Then I should get 10 results
|
73
|
-
|
75
|
+
|
74
76
|
When I flag alpha five as inactive
|
75
77
|
And I wait for Sphinx to catch up
|
76
78
|
And I filter by active alphas
|
@@ -2,50 +2,52 @@ Feature: Keeping Sphinx in line with deleted model instances
|
|
2
2
|
In order to avoid deleted items being returned by Sphinx
|
3
3
|
Thinking Sphinx
|
4
4
|
Should keep deleted items out of search results
|
5
|
-
|
5
|
+
|
6
6
|
Scenario: Deleting instances from the core index
|
7
7
|
Given Sphinx is running
|
8
8
|
And I am searching on betas
|
9
9
|
When I search for three
|
10
10
|
Then I should get 1 result
|
11
|
-
|
11
|
+
|
12
12
|
When I destroy beta three
|
13
13
|
And I wait for Sphinx to catch up
|
14
14
|
And I search for three
|
15
15
|
Then I should get 0 results
|
16
|
-
|
16
|
+
|
17
17
|
Scenario: Deleting subclasses when the parent class is indexed
|
18
18
|
Given Sphinx is running
|
19
19
|
And I am searching on cats
|
20
20
|
When I search for moggy
|
21
21
|
Then I should get 1 result
|
22
|
-
|
22
|
+
|
23
23
|
When I destroy cat moggy
|
24
24
|
And I wait for Sphinx to catch up
|
25
25
|
And I search for moggy
|
26
26
|
Then I should get 0 results
|
27
|
-
|
27
|
+
|
28
28
|
Scenario: Deleting created instances from the delta index
|
29
29
|
Given Sphinx is running
|
30
30
|
And I am searching on betas
|
31
|
-
When I create a new beta named
|
31
|
+
When I create a new beta named eighteen
|
32
32
|
And I wait for Sphinx to catch up
|
33
|
-
And I
|
33
|
+
And I clear the connection pool
|
34
|
+
And I search for eighteen
|
34
35
|
Then I should get 1 result
|
35
|
-
|
36
|
-
When I destroy beta
|
36
|
+
|
37
|
+
When I destroy beta eighteen
|
37
38
|
And I wait for Sphinx to catch up
|
38
|
-
And I search for
|
39
|
+
And I search for eighteen
|
39
40
|
Then I should get 0 results
|
40
|
-
|
41
|
+
|
41
42
|
Scenario: Deleting edited instances from the delta index
|
42
43
|
Given Sphinx is running
|
43
44
|
And I am searching on betas
|
44
45
|
When I change the name of beta four to fourteen
|
45
46
|
And I wait for Sphinx to catch up
|
47
|
+
And I clear the connection pool
|
46
48
|
And I search for fourteen
|
47
49
|
Then I should get 1 result
|
48
|
-
|
50
|
+
|
49
51
|
When I destroy beta fourteen
|
50
52
|
And I wait for Sphinx to catch up
|
51
53
|
And I search for fourteen
|
@@ -56,9 +58,10 @@ Feature: Keeping Sphinx in line with deleted model instances
|
|
56
58
|
And I am searching on betas
|
57
59
|
When I create a new beta named thirteen
|
58
60
|
And I wait for Sphinx to catch up
|
61
|
+
And I clear the connection pool
|
59
62
|
And I search for thirteen
|
60
63
|
Then I should get 1 result
|
61
|
-
|
64
|
+
|
62
65
|
And I disable delta updates
|
63
66
|
And I destroy beta thirteen
|
64
67
|
And I wait for Sphinx to catch up
|
@@ -2,72 +2,75 @@ Feature: Keeping Sphinx in line with model changes when requested
|
|
2
2
|
In order to keep indexes as up to date as possible
|
3
3
|
Thinking Sphinx
|
4
4
|
Should return the expected results depending on whether delta indexes are used
|
5
|
-
|
5
|
+
|
6
6
|
Scenario: Returning instance from old data if there is no delta
|
7
7
|
Given Sphinx is running
|
8
8
|
And I am searching on alphas
|
9
9
|
When I search for two
|
10
10
|
Then I should get 1 result
|
11
|
-
|
11
|
+
|
12
12
|
When I change the name of alpha two to twelve
|
13
13
|
And I wait for Sphinx to catch up
|
14
14
|
And I search for two
|
15
15
|
Then I should get 1 result
|
16
|
-
|
16
|
+
|
17
17
|
Scenario: Not returning an instance from old data if there is a delta
|
18
18
|
Given Sphinx is running
|
19
19
|
And I am searching on betas
|
20
20
|
When I search for two
|
21
21
|
Then I should get 1 result
|
22
|
-
|
22
|
+
|
23
23
|
When I change the name of beta two to twelve
|
24
24
|
And I wait for Sphinx to catch up
|
25
|
+
And I clear the connection pool
|
25
26
|
And I search for two
|
26
27
|
Then I should get 0 results
|
27
|
-
|
28
|
+
|
28
29
|
Scenario: Returning instance from new data if there is a delta
|
29
30
|
Given Sphinx is running
|
30
31
|
And I am searching on betas
|
31
32
|
When I search for one
|
32
33
|
Then I should get 1 result
|
33
|
-
|
34
|
+
|
34
35
|
When I change the name of beta one to eleventeen
|
35
36
|
And I wait for Sphinx to catch up
|
37
|
+
And I clear the connection pool
|
36
38
|
And I search for one
|
37
39
|
Then I should get 0 results
|
38
|
-
|
40
|
+
|
39
41
|
When I search for eleventeen
|
40
42
|
Then I should get 1 result
|
41
|
-
|
43
|
+
|
42
44
|
Scenario: Returning new records if there's a delta
|
43
45
|
Given Sphinx is running
|
44
46
|
And I am searching on betas
|
45
47
|
When I search for fifteen
|
46
48
|
Then I should get 0 results
|
47
|
-
|
49
|
+
|
48
50
|
When I create a new beta named fifteen
|
49
51
|
And I wait for Sphinx to catch up
|
52
|
+
And I clear the connection pool
|
50
53
|
And I search for fifteen
|
51
54
|
Then I should get 1 result
|
52
|
-
|
55
|
+
|
53
56
|
Scenario: Avoiding delta updates if there hasn't been changes
|
54
57
|
Given Sphinx is running
|
55
58
|
And I am searching on betas
|
56
59
|
When I search for five
|
57
60
|
Then I should get 1 result
|
58
|
-
|
61
|
+
|
59
62
|
When I change the name of beta five to five
|
60
63
|
And I wait for Sphinx to catch up
|
61
64
|
And I search for five
|
62
65
|
Then I should get 1 result
|
63
|
-
|
66
|
+
|
64
67
|
When I search for the document id of beta five in the beta_core index
|
65
68
|
Then it should exist if using Rails 2.1 or newer
|
66
69
|
When I search for the document id of beta five in the secondary_beta_core index
|
67
70
|
Then it should exist if using Rails 2.1 or newer
|
68
71
|
When I search for the document id of beta five in the secondary_beta_delta index
|
69
72
|
Then it should not exist if using Rails 2.1 or newer
|
70
|
-
|
73
|
+
|
71
74
|
Scenario: Handling edits with a delta when Sphinx isn't running
|
72
75
|
Given Sphinx is running
|
73
76
|
And I am searching on betas
|
@@ -76,19 +79,19 @@ Feature: Keeping Sphinx in line with model changes when requested
|
|
76
79
|
And I start Sphinx
|
77
80
|
And I search for sixteen
|
78
81
|
Then I should get 1 result
|
79
|
-
|
82
|
+
|
80
83
|
Scenario: Handling edits when updates are disabled
|
81
84
|
Given Sphinx is running
|
82
85
|
And updates are disabled
|
83
86
|
And I am searching on betas
|
84
|
-
|
87
|
+
|
85
88
|
When I search for seven
|
86
89
|
Then I should get 1 result
|
87
|
-
|
90
|
+
|
88
91
|
When I change the name of beta seven to seventeen
|
89
92
|
And I wait for Sphinx to catch up
|
90
93
|
And I search for seven
|
91
94
|
Then I should get 1 result
|
92
|
-
|
95
|
+
|
93
96
|
When I search for seventeen
|
94
97
|
Then I should get 0 results
|
@@ -2,21 +2,21 @@ Feature: Searching within a single index
|
|
2
2
|
In order to use Thinking Sphinx's core functionality
|
3
3
|
A developer
|
4
4
|
Should be able to search on a single index
|
5
|
-
|
5
|
+
|
6
6
|
Scenario: Searching with alternative index
|
7
7
|
Given Sphinx is running
|
8
8
|
And I am searching on alphas
|
9
9
|
When I order by value
|
10
10
|
And I use index alternative_core
|
11
11
|
Then I should get 7 results
|
12
|
-
|
12
|
+
|
13
13
|
Scenario: Searching with default index
|
14
14
|
Given Sphinx is running
|
15
15
|
And I am searching on alphas
|
16
16
|
When I order by value
|
17
17
|
And I use index alpha_core
|
18
18
|
Then I should get 10 results
|
19
|
-
|
19
|
+
|
20
20
|
Scenario: Searching without specified index
|
21
21
|
Given Sphinx is running
|
22
22
|
And I am searching on alphas
|
@@ -26,14 +26,15 @@ Feature: Searching within a single index
|
|
26
26
|
Scenario: Deleting instances from the core index
|
27
27
|
Given Sphinx is running
|
28
28
|
And I am searching on alphas
|
29
|
-
|
29
|
+
|
30
30
|
When I create a new alpha named eleven
|
31
31
|
And I process the alpha_core index
|
32
32
|
And I process the alternative_core index
|
33
33
|
And I wait for Sphinx to catch up
|
34
|
+
And I clear the connection pool
|
34
35
|
And I search for eleven
|
35
36
|
Then I should get 1 result
|
36
|
-
|
37
|
+
|
37
38
|
When I destroy alpha eleven
|
38
39
|
And I wait for Sphinx to catch up
|
39
40
|
And I search for eleven
|
data/features/support/env.rb
CHANGED
@@ -5,9 +5,6 @@ require 'bundler'
|
|
5
5
|
Bundler.require :default, :development
|
6
6
|
|
7
7
|
$:.unshift File.dirname(__FILE__) + '/../../lib'
|
8
|
-
Dir[File.join(File.dirname(__FILE__), '../../vendor/*/lib')].each do |path|
|
9
|
-
$:.unshift path
|
10
|
-
end
|
11
8
|
|
12
9
|
require 'active_record'
|
13
10
|
require 'cucumber/thinking_sphinx/internal_world'
|
data/lib/thinking_sphinx.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'thread'
|
2
2
|
require 'active_record'
|
3
|
+
require 'innertube'
|
3
4
|
require 'yaml'
|
4
5
|
require 'riddle'
|
5
6
|
|
@@ -11,6 +12,7 @@ require 'thinking_sphinx/association'
|
|
11
12
|
require 'thinking_sphinx/attribute'
|
12
13
|
require 'thinking_sphinx/bundled_search'
|
13
14
|
require 'thinking_sphinx/configuration'
|
15
|
+
require 'thinking_sphinx/connection'
|
14
16
|
require 'thinking_sphinx/context'
|
15
17
|
require 'thinking_sphinx/excerpter'
|
16
18
|
require 'thinking_sphinx/facet'
|
@@ -23,7 +25,6 @@ require 'thinking_sphinx/source'
|
|
23
25
|
require 'thinking_sphinx/search'
|
24
26
|
require 'thinking_sphinx/search_methods'
|
25
27
|
require 'thinking_sphinx/deltas'
|
26
|
-
require 'thinking_sphinx/version'
|
27
28
|
|
28
29
|
require 'thinking_sphinx/adapters/abstract_adapter'
|
29
30
|
require 'thinking_sphinx/adapters/mysql_adapter'
|
@@ -293,5 +294,11 @@ module ThinkingSphinx
|
|
293
294
|
!!defined?(::ActiveRecord::Associations::CollectionProxy)
|
294
295
|
end
|
295
296
|
|
297
|
+
def self.before_index_hooks
|
298
|
+
@before_index_hooks
|
299
|
+
end
|
300
|
+
|
301
|
+
@before_index_hooks = []
|
302
|
+
|
296
303
|
extend ThinkingSphinx::SearchMethods::ClassMethods
|
297
304
|
end
|
@@ -270,9 +270,9 @@ module ThinkingSphinx
|
|
270
270
|
def delete_in_index(index, document_id)
|
271
271
|
return unless ThinkingSphinx.sphinx_running?
|
272
272
|
|
273
|
-
ThinkingSphinx::
|
274
|
-
index, ['sphinx_deleted'], {document_id => [1]}
|
275
|
-
|
273
|
+
ThinkingSphinx::Connection.take do |client|
|
274
|
+
client.update index, ['sphinx_deleted'], {document_id => [1]}
|
275
|
+
end
|
276
276
|
rescue Riddle::ConnectionError, Riddle::ResponseError,
|
277
277
|
ThinkingSphinx::SphinxError, Errno::ETIMEDOUT, Timeout::Error
|
278
278
|
# Not the end of the world if Sphinx isn't running.
|
@@ -40,10 +40,11 @@ module ThinkingSphinx
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def update_index(index_name, attribute_names, attribute_values)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
ThinkingSphinx::Connection.take do |client|
|
44
|
+
client.update index_name, attribute_names, {
|
45
|
+
sphinx_document_id => attribute_values
|
46
|
+
}
|
47
|
+
end
|
47
48
|
rescue Riddle::ConnectionError, Riddle::ResponseError,
|
48
49
|
ThinkingSphinx::SphinxError, Errno::ETIMEDOUT
|
49
50
|
# Not the end of the world if Sphinx isn't running.
|
@@ -51,6 +51,13 @@ module ThinkingSphinx
|
|
51
51
|
:mysql
|
52
52
|
when "jdbcpostgresql"
|
53
53
|
:postgresql
|
54
|
+
when "jdbc"
|
55
|
+
match = /^jdbc:(mysql|postgresql):\/\//.match(model.connection.config[:url])
|
56
|
+
if match
|
57
|
+
match[1].to_sym
|
58
|
+
else
|
59
|
+
model.connection.config[:adapter]
|
60
|
+
end
|
54
61
|
else
|
55
62
|
model.connection.config[:adapter].to_sym
|
56
63
|
end
|
@@ -14,7 +14,7 @@ module ThinkingSphinx
|
|
14
14
|
else
|
15
15
|
documentation_link = %Q{
|
16
16
|
For more information, read the documentation:
|
17
|
-
http://pat.github.
|
17
|
+
http://pat.github.io/thinking-sphinx/advanced_config.html
|
18
18
|
}
|
19
19
|
|
20
20
|
if version.nil? || version.empty?
|