thinking-sphinx 3.4.1 → 3.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +7 -0
- data/README.textile +3 -2
- data/lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb +11 -3
- data/lib/thinking_sphinx/active_record/log_subscriber.rb +2 -2
- data/lib/thinking_sphinx/middlewares/valid_options.rb +1 -1
- data/lib/thinking_sphinx/real_time.rb +1 -1
- data/lib/thinking_sphinx/real_time/populator.rb +0 -6
- data/lib/thinking_sphinx/search.rb +10 -6
- data/spec/acceptance/real_time_updates_spec.rb +11 -0
- data/spec/internal/app/indices/admin_person_index.rb +4 -0
- data/spec/internal/app/models/admin/person.rb +2 -0
- data/spec/thinking_sphinx/active_record/callbacks/delete_callbacks_spec.rb +59 -0
- data/spec/thinking_sphinx/middlewares/valid_options_spec.rb +1 -1
- data/thinking-sphinx.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99b138f1d9126e0d6071b1c86708a5f5b6150701
|
4
|
+
data.tar.gz: d193fea1540911cff9466850ce3200a4841bd3df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3abb0b6a5c4f6403c166859d32e1bd8078f804e1a9c873e312487d4da47b94d21ac82e9dedba23903f1f97ba23aba5e3eb2c8a8d27e2ac559ec276f3d8af76f
|
7
|
+
data.tar.gz: 0f612c12b09401f5f8a2c03b8a2e3129b7b7baf06977bb8e89e92dfae40bb9fd8655907c0b15d2c319c2978affbe31c9d35c8ef50f726e01545596ea3abbf06d
|
data/HISTORY
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
2017-09-29: 3.4.2
|
2
|
+
* [FIX] Real-time callback syntax for namespaced models accepts a string (as documented).
|
3
|
+
* [CHANGE] Allow use of deletion callbacks for rollback events.
|
4
|
+
* [CHANGE] Remove extra deletion code in the Populator - it's also being done by the real-time rake interface.
|
5
|
+
* [FIX] Fix up logged warnings.
|
6
|
+
* [FIX] Add missing search options to known values to avoid incorrect warnings.
|
7
|
+
|
1
8
|
2017-08-29: 3.4.1
|
2
9
|
* [CHANGE] Treat "Lost connection to MySQL server" as a connection error (Manuel Schnitzer).
|
3
10
|
* [FIX] Index normalisation will now work even when index model tables don't exist.
|
data/README.textile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
h1. Thinking Sphinx
|
2
2
|
|
3
|
-
Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v3.4.
|
3
|
+
Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v3.4.2.
|
4
4
|
|
5
5
|
h2. Upgrading
|
6
6
|
|
7
7
|
Please refer to the release notes for any changes you need to make when upgrading:
|
8
8
|
|
9
|
+
* "v3.4.2":https://github.com/pat/thinking-sphinx/releases/tag/v3.4.2
|
9
10
|
* "v3.4.1":https://github.com/pat/thinking-sphinx/releases/tag/v3.4.1
|
10
11
|
* "v3.4.0":https://github.com/pat/thinking-sphinx/releases/tag/v3.4.0
|
11
12
|
* "v3.3.0":https://github.com/pat/thinking-sphinx/releases/tag/v3.3.0
|
@@ -25,7 +26,7 @@ It's a gem, so install it like you would any other gem. You will also need to sp
|
|
25
26
|
|
26
27
|
<pre><code>gem 'mysql2', '~> 0.3', :platform => :ruby
|
27
28
|
gem 'jdbc-mysql', '= 5.1.35', :platform => :jruby
|
28
|
-
gem 'thinking-sphinx', '~> 3.4.
|
29
|
+
gem 'thinking-sphinx', '~> 3.4.2'</code></pre>
|
29
30
|
|
30
31
|
The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database. If you're using JRuby, there is "currently an issue with Sphinx and jdbc-mysql 5.1.36 or newer":http://sphinxsearch.com/forum/view.html?id=13939, so you'll need to stick to nothing more recent than 5.1.35.
|
31
32
|
|
@@ -1,9 +1,19 @@
|
|
1
1
|
class ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks <
|
2
2
|
ThinkingSphinx::Callbacks
|
3
3
|
|
4
|
-
callbacks :after_destroy
|
4
|
+
callbacks :after_destroy, :after_rollback
|
5
5
|
|
6
6
|
def after_destroy
|
7
|
+
delete_from_sphinx
|
8
|
+
end
|
9
|
+
|
10
|
+
def after_rollback
|
11
|
+
delete_from_sphinx
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def delete_from_sphinx
|
7
17
|
return if ThinkingSphinx::Callbacks.suspended? || instance.new_record?
|
8
18
|
|
9
19
|
indices.each { |index|
|
@@ -11,8 +21,6 @@ class ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks <
|
|
11
21
|
}
|
12
22
|
end
|
13
23
|
|
14
|
-
private
|
15
|
-
|
16
24
|
def indices
|
17
25
|
ThinkingSphinx::Configuration.instance.index_set_class.new(
|
18
26
|
:classes => [instance.class]
|
@@ -14,9 +14,9 @@ class ThinkingSphinx::ActiveRecord::LogSubscriber < ActiveSupport::LogSubscriber
|
|
14
14
|
debug " #{identifier} #{event.payload[:query]}"
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def caution(event)
|
18
18
|
identifier = color 'Sphinx', GREEN, true
|
19
|
-
warn " #{identifier} #{event.payload[:
|
19
|
+
warn " #{identifier} #{event.payload[:caution]}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -10,8 +10,6 @@ class ThinkingSphinx::RealTime::Populator
|
|
10
10
|
def populate(&block)
|
11
11
|
instrument 'start_populating'
|
12
12
|
|
13
|
-
remove_files
|
14
|
-
|
15
13
|
scope.find_in_batches(:batch_size => batch_size) do |instances|
|
16
14
|
transcriber.copy *instances
|
17
15
|
instrument 'populated', :instances => instances
|
@@ -38,10 +36,6 @@ class ThinkingSphinx::RealTime::Populator
|
|
38
36
|
)
|
39
37
|
end
|
40
38
|
|
41
|
-
def remove_files
|
42
|
-
Dir["#{index.path}*"].each { |file| FileUtils.rm file }
|
43
|
-
end
|
44
|
-
|
45
39
|
def transcriber
|
46
40
|
@transcriber ||= ThinkingSphinx::RealTime::Transcriber.new index
|
47
41
|
end
|
@@ -6,6 +6,15 @@ class ThinkingSphinx::Search < Array
|
|
6
6
|
respond_to_missing? send should should_not type )
|
7
7
|
SAFE_METHODS = %w( partition private_methods protected_methods public_methods
|
8
8
|
send class )
|
9
|
+
KNOWN_OPTIONS = (
|
10
|
+
[
|
11
|
+
:classes, :conditions, :geo, :group_by, :ids_only, :ignore_scopes,
|
12
|
+
:indices, :limit, :masks, :max_matches, :middleware, :offset, :order,
|
13
|
+
:order_group_by, :page, :per_page, :populate, :retry_stale, :select,
|
14
|
+
:skip_sti, :sql, :star, :with, :with_all, :without, :without_ids
|
15
|
+
] +
|
16
|
+
ThinkingSphinx::Middlewares::SphinxQL::SELECT_OPTIONS
|
17
|
+
).uniq
|
9
18
|
DEFAULT_MASKS = [
|
10
19
|
ThinkingSphinx::Masks::PaginationMask,
|
11
20
|
ThinkingSphinx::Masks::ScopesMask,
|
@@ -25,12 +34,7 @@ class ThinkingSphinx::Search < Array
|
|
25
34
|
@valid_options
|
26
35
|
end
|
27
36
|
|
28
|
-
@valid_options =
|
29
|
-
:classes, :conditions, :geo, :group_by, :ids_only, :ignore_scopes, :indices,
|
30
|
-
:limit, :masks, :max_matches, :middleware, :offset, :order, :order_group_by,
|
31
|
-
:page, :per_page, :populate, :retry_stale, :select, :skip_sti, :sql, :star,
|
32
|
-
:with, :with_all, :without, :without_ids
|
33
|
-
]
|
37
|
+
@valid_options = KNOWN_OPTIONS.dup
|
34
38
|
|
35
39
|
def initialize(query = nil, options = {})
|
36
40
|
query, options = nil, query if query.is_a?(Hash)
|
@@ -14,4 +14,15 @@ describe 'Updates to records in real-time indices', :live => true do
|
|
14
14
|
expect(Product.search('blue fish', :indices => ['product_core']).to_a).
|
15
15
|
to eq([product])
|
16
16
|
end
|
17
|
+
|
18
|
+
it "handles inserts and updates for namespaced models" do
|
19
|
+
person = Admin::Person.create :name => 'Death'
|
20
|
+
|
21
|
+
expect(Admin::Person.search('Death').to_a).to eq([person])
|
22
|
+
|
23
|
+
person.update_attributes :name => 'Mort'
|
24
|
+
|
25
|
+
expect(Admin::Person.search('Death').to_a).to be_empty
|
26
|
+
expect(Admin::Person.search('Mort').to_a).to eq([person])
|
27
|
+
end
|
17
28
|
end
|
@@ -64,4 +64,63 @@ describe ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks do
|
|
64
64
|
ThinkingSphinx::Callbacks.resume!
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
describe '.after_rollback' do
|
69
|
+
let(:callbacks) { double('callbacks', :after_rollback => nil) }
|
70
|
+
|
71
|
+
before :each do
|
72
|
+
allow(ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks).
|
73
|
+
to receive_messages :new => callbacks
|
74
|
+
end
|
75
|
+
|
76
|
+
it "builds an object from the instance" do
|
77
|
+
expect(ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks).
|
78
|
+
to receive(:new).with(instance).and_return(callbacks)
|
79
|
+
|
80
|
+
ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks.
|
81
|
+
after_rollback(instance)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "invokes after_rollback on the object" do
|
85
|
+
expect(callbacks).to receive(:after_rollback)
|
86
|
+
|
87
|
+
ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks.
|
88
|
+
after_rollback(instance)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#after_rollback' do
|
93
|
+
let(:index_set) { double 'index set', :to_a => [index] }
|
94
|
+
let(:index) { double('index', :name => 'foo_core',
|
95
|
+
:document_id_for_key => 14, :type => 'plain', :distributed? => false) }
|
96
|
+
let(:instance) { double('instance', :id => 7, :new_record? => false) }
|
97
|
+
|
98
|
+
before :each do
|
99
|
+
allow(ThinkingSphinx::IndexSet).to receive_messages :new => index_set
|
100
|
+
end
|
101
|
+
|
102
|
+
it "performs the deletion for the index and instance" do
|
103
|
+
expect(ThinkingSphinx::Deletion).to receive(:perform).with(index, 7)
|
104
|
+
|
105
|
+
callbacks.after_rollback
|
106
|
+
end
|
107
|
+
|
108
|
+
it "doesn't do anything if the instance is a new record" do
|
109
|
+
allow(instance).to receive_messages :new_record? => true
|
110
|
+
|
111
|
+
expect(ThinkingSphinx::Deletion).not_to receive(:perform)
|
112
|
+
|
113
|
+
callbacks.after_rollback
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'does nothing if callbacks are suspended' do
|
117
|
+
ThinkingSphinx::Callbacks.suspend!
|
118
|
+
|
119
|
+
expect(ThinkingSphinx::Deletion).not_to receive(:perform)
|
120
|
+
|
121
|
+
callbacks.after_rollback
|
122
|
+
|
123
|
+
ThinkingSphinx::Callbacks.resume!
|
124
|
+
end
|
125
|
+
end
|
67
126
|
end
|
@@ -17,7 +17,7 @@ RSpec.describe ThinkingSphinx::Middlewares::ValidOptions do
|
|
17
17
|
|
18
18
|
it "adds a warning" do
|
19
19
|
expect(ThinkingSphinx::Logger).to receive(:log).
|
20
|
-
with(:
|
20
|
+
with(:caution, "Unexpected search options: [:foo]")
|
21
21
|
|
22
22
|
middleware.call [context]
|
23
23
|
end
|
data/thinking-sphinx.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thinking-sphinx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -495,7 +495,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
495
495
|
version: '0'
|
496
496
|
requirements: []
|
497
497
|
rubyforge_project: thinking-sphinx
|
498
|
-
rubygems_version: 2.6.
|
498
|
+
rubygems_version: 2.6.13
|
499
499
|
signing_key:
|
500
500
|
specification_version: 4
|
501
501
|
summary: A smart wrapper over Sphinx for ActiveRecord
|