thinking-sphinx 5.0.0 → 5.3.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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +152 -0
- data/.travis.yml +4 -4
- data/Appraisals +9 -3
- data/CHANGELOG.markdown +57 -1
- data/README.textile +8 -8
- data/bin/loadsphinx +13 -5
- data/lib/thinking_sphinx.rb +0 -3
- data/lib/thinking_sphinx/active_record.rb +3 -0
- data/lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb +1 -1
- data/lib/thinking_sphinx/active_record/callbacks/association_delta_callbacks.rb +21 -0
- data/lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb +5 -1
- data/lib/thinking_sphinx/callbacks/appender.rb +31 -15
- data/lib/thinking_sphinx/connection.rb +4 -0
- data/lib/thinking_sphinx/connection/client.rb +6 -1
- data/lib/thinking_sphinx/errors.rb +1 -1
- data/lib/thinking_sphinx/railtie.rb +14 -7
- data/lib/thinking_sphinx/real_time/index.rb +1 -3
- data/lib/thinking_sphinx/real_time/index/template.rb +12 -0
- data/lib/thinking_sphinx/real_time/populator.rb +4 -1
- data/lib/thinking_sphinx/real_time/transcriber.rb +6 -0
- data/lib/thinking_sphinx/real_time/translator.rb +1 -0
- data/lib/thinking_sphinx/search/stale_ids_exception.rb +2 -1
- data/lib/thinking_sphinx/settings.rb +13 -9
- data/lib/thinking_sphinx/sinatra.rb +1 -1
- data/spec/acceptance/geosearching_spec.rb +13 -3
- data/spec/acceptance/sql_deltas_spec.rb +13 -1
- data/spec/acceptance/support/sphinx_helpers.rb +4 -4
- data/spec/internal/app/indices/article_index.rb +0 -1
- data/spec/internal/app/indices/colour_index.rb +7 -0
- data/spec/internal/app/models/colour.rb +2 -0
- data/spec/internal/app/models/tee.rb +3 -0
- data/spec/internal/config/database.yml +6 -1
- data/spec/internal/db/schema.rb +1 -0
- data/spec/thinking_sphinx/active_record/index_spec.rb +3 -1
- data/spec/thinking_sphinx/active_record/sql_source_spec.rb +3 -3
- data/spec/thinking_sphinx/connection/mri_spec.rb +49 -0
- data/spec/thinking_sphinx/real_time/index_spec.rb +13 -1
- data/thinking-sphinx.gemspec +1 -1
- metadata +11 -7
- data/spec/acceptance/connection_spec.rb +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55eace64045aea4431c8a86005e70485efacfb15cc6768098c19fa89c4098d8c
|
|
4
|
+
data.tar.gz: e13db8a3a331535dd73aed4ffb965a130fdf8ae57df4241cafb4c6e1b421305f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a9d79a7a86ca0c6f9968bae9c980049174626d12d44b8cafa73139be5bf24c66d3675a5e16a3a104d5b04ce76b1a0e136e2cc788338c142107af9354eca8e7d
|
|
7
|
+
data.tar.gz: be890cb3de5d4a5885c6bcc213349bfb656567f2b4cc63decabbd608bf7004126358fd13b42e6b3a6271e25db19f85c2dc061ed2c1b862e7f968276fa7632377
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
orbs:
|
|
4
|
+
ruby: circleci/ruby@1.0
|
|
5
|
+
|
|
6
|
+
workflows:
|
|
7
|
+
test:
|
|
8
|
+
jobs:
|
|
9
|
+
- test:
|
|
10
|
+
name: "Sphinx 2.2.11 with MySQL"
|
|
11
|
+
database: mysql2
|
|
12
|
+
sphinx_version: 2.2.11
|
|
13
|
+
sphinx_engine: sphinx
|
|
14
|
+
debian: jessie
|
|
15
|
+
ruby: '2.4.6'
|
|
16
|
+
- test:
|
|
17
|
+
name: "Sphinx 2.2.11 with PostgreSQL"
|
|
18
|
+
database: postgresql
|
|
19
|
+
sphinx_version: 2.2.11
|
|
20
|
+
sphinx_engine: sphinx
|
|
21
|
+
debian: jessie
|
|
22
|
+
ruby: '2.4.6'
|
|
23
|
+
- test:
|
|
24
|
+
name: "Sphinx 3.3.1 with MySQL"
|
|
25
|
+
database: mysql2
|
|
26
|
+
sphinx_version: 3.3.1
|
|
27
|
+
sphinx_engine: sphinx
|
|
28
|
+
debian: buster
|
|
29
|
+
matrix:
|
|
30
|
+
parameters:
|
|
31
|
+
ruby: [ '2.4.9', '2.5.8', '2.6.6', '2.7.2', '3.0.0' ]
|
|
32
|
+
# - test:
|
|
33
|
+
# database: postgresql
|
|
34
|
+
# sphinx_version: 3.3.1
|
|
35
|
+
# sphinx_engine: sphinx
|
|
36
|
+
# matrix:
|
|
37
|
+
# parameters:
|
|
38
|
+
# ruby: [ '2.4', '2.5', '2.6', '2.7' ]
|
|
39
|
+
- test:
|
|
40
|
+
name: "Manticore 2.8.2 with MySQL"
|
|
41
|
+
database: mysql2
|
|
42
|
+
sphinx_version: 2.8.2
|
|
43
|
+
sphinx_engine: manticore
|
|
44
|
+
debian: stretch
|
|
45
|
+
matrix:
|
|
46
|
+
parameters:
|
|
47
|
+
ruby: [ '2.4.9', '2.5.8', '2.6.6' ]
|
|
48
|
+
- test:
|
|
49
|
+
name: "Manticore 2.8.2 with PostgreSQL"
|
|
50
|
+
database: postgresql
|
|
51
|
+
sphinx_version: 2.8.2
|
|
52
|
+
sphinx_engine: manticore
|
|
53
|
+
debian: stretch
|
|
54
|
+
matrix:
|
|
55
|
+
parameters:
|
|
56
|
+
ruby: [ '2.4.9', '2.5.8', '2.6.6' ]
|
|
57
|
+
- test:
|
|
58
|
+
name: "Manticore 3.5.4 with MySQL"
|
|
59
|
+
database: mysql2
|
|
60
|
+
sphinx_version: 3.5.4
|
|
61
|
+
sphinx_engine: manticore
|
|
62
|
+
debian: buster
|
|
63
|
+
matrix:
|
|
64
|
+
parameters:
|
|
65
|
+
ruby: [ '2.4.9', '2.5.8', '2.6.6', '2.7.2', '3.0.0' ]
|
|
66
|
+
- test:
|
|
67
|
+
name: "Manticore 3.5.4 with PostgreSQL"
|
|
68
|
+
database: postgresql
|
|
69
|
+
sphinx_version: 3.5.4
|
|
70
|
+
sphinx_engine: manticore
|
|
71
|
+
debian: buster
|
|
72
|
+
matrix:
|
|
73
|
+
parameters:
|
|
74
|
+
ruby: [ '2.4.9', '2.5.8', '2.6.6', '2.7.2', '3.0.0' ]
|
|
75
|
+
|
|
76
|
+
jobs:
|
|
77
|
+
test:
|
|
78
|
+
parameters:
|
|
79
|
+
ruby:
|
|
80
|
+
type: string
|
|
81
|
+
database:
|
|
82
|
+
type: string
|
|
83
|
+
sphinx_version:
|
|
84
|
+
type: string
|
|
85
|
+
sphinx_engine:
|
|
86
|
+
type: string
|
|
87
|
+
debian:
|
|
88
|
+
type: string
|
|
89
|
+
|
|
90
|
+
docker:
|
|
91
|
+
- image: circleci/ruby:<< parameters.ruby >>-<< parameters.debian >>
|
|
92
|
+
|
|
93
|
+
- image: circleci/postgres:10
|
|
94
|
+
environment:
|
|
95
|
+
POSTGRES_USER: postgres
|
|
96
|
+
POSTGRES_PASSWORD: thinking_sphinx
|
|
97
|
+
POSTGRES_DB: thinking_sphinx
|
|
98
|
+
|
|
99
|
+
- image: circleci/mysql:5.7
|
|
100
|
+
environment:
|
|
101
|
+
MYSQL_ROOT_PASSWORD: thinking_sphinx
|
|
102
|
+
MYSQL_DATABASE: thinking_sphinx
|
|
103
|
+
|
|
104
|
+
working_directory: ~/app
|
|
105
|
+
|
|
106
|
+
steps:
|
|
107
|
+
- checkout
|
|
108
|
+
|
|
109
|
+
- restore_cache:
|
|
110
|
+
keys:
|
|
111
|
+
- v1-dependencies-<< parameters.ruby >>
|
|
112
|
+
|
|
113
|
+
- run:
|
|
114
|
+
name: install bundler
|
|
115
|
+
command: |
|
|
116
|
+
if [ "<< parameters.ruby >>" == "2.7.2" ]; then
|
|
117
|
+
export BUNDLER_VERSION=2.1.4
|
|
118
|
+
elif [ "<< parameters.ruby >>" == "3.0.0" ]; then
|
|
119
|
+
export BUNDLER_VERSION=2.1.4
|
|
120
|
+
else
|
|
121
|
+
export BUNDLER_VERSION=1.17.3
|
|
122
|
+
fi
|
|
123
|
+
export BUNDLE_PATH=vendor/bundle
|
|
124
|
+
gem install bundler:$BUNDLER_VERSION
|
|
125
|
+
|
|
126
|
+
- run:
|
|
127
|
+
name: install dependencies
|
|
128
|
+
command: |
|
|
129
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
|
130
|
+
bundle update
|
|
131
|
+
|
|
132
|
+
- run:
|
|
133
|
+
name: set up appraisal
|
|
134
|
+
command: bundle exec appraisal update
|
|
135
|
+
|
|
136
|
+
- save_cache:
|
|
137
|
+
paths:
|
|
138
|
+
- ./vendor/bundle
|
|
139
|
+
key: v1-dependencies-<< parameters.ruby >>
|
|
140
|
+
|
|
141
|
+
- run:
|
|
142
|
+
name: set up sphinx
|
|
143
|
+
command: "./bin/loadsphinx << parameters.sphinx_version >> << parameters.sphinx_engine >>"
|
|
144
|
+
|
|
145
|
+
- run:
|
|
146
|
+
name: tests
|
|
147
|
+
environment:
|
|
148
|
+
CI: "true"
|
|
149
|
+
DATABASE: << parameters.database >>
|
|
150
|
+
SPHINX_VERSION: << parameters.sphinx_version >>
|
|
151
|
+
SPHINX_ENGINE: << parameters.sphinx_engine >>
|
|
152
|
+
command: bundle exec appraisal rspec
|
data/.travis.yml
CHANGED
|
@@ -19,12 +19,12 @@ env:
|
|
|
19
19
|
matrix:
|
|
20
20
|
- DATABASE=mysql2 SPHINX_VERSION=2.2.11 SPHINX_ENGINE=sphinx
|
|
21
21
|
- DATABASE=postgresql SPHINX_VERSION=2.2.11 SPHINX_ENGINE=sphinx
|
|
22
|
-
- DATABASE=mysql2 SPHINX_VERSION=3.
|
|
22
|
+
- DATABASE=mysql2 SPHINX_VERSION=3.3.1 SPHINX_ENGINE=sphinx
|
|
23
23
|
- DATABASE=mysql2 SPHINX_VERSION=2.8.2 SPHINX_ENGINE=manticore
|
|
24
24
|
- DATABASE=postgresql SPHINX_VERSION=2.8.2 SPHINX_ENGINE=manticore
|
|
25
|
-
- DATABASE=mysql2 SPHINX_VERSION=3.
|
|
26
|
-
- DATABASE=postgresql SPHINX_VERSION=3.
|
|
27
|
-
# - DATABASE=postgresql SPHINX_VERSION=3.
|
|
25
|
+
- DATABASE=mysql2 SPHINX_VERSION=3.5.0 SPHINX_ENGINE=manticore
|
|
26
|
+
- DATABASE=postgresql SPHINX_VERSION=3.5.0 SPHINX_ENGINE=manticore
|
|
27
|
+
# - DATABASE=postgresql SPHINX_VERSION=3.3.1 SPHINX_ENGINE=sphinx
|
|
28
28
|
sudo: false
|
|
29
29
|
addons:
|
|
30
30
|
postgresql: '9.4'
|
data/Appraisals
CHANGED
|
@@ -15,21 +15,27 @@ appraise 'rails_5_0' do
|
|
|
15
15
|
gem 'jdbc-mysql', '~> 5.1.36', :platform => :jruby
|
|
16
16
|
gem 'activerecord-jdbcmysql-adapter', '~> 50.0', :platform => :jruby
|
|
17
17
|
gem 'activerecord-jdbcpostgresql-adapter', '~> 50.0', :platform => :jruby
|
|
18
|
-
end if RUBY_PLATFORM != "java" || ENV["SPHINX_VERSION"].to_f > 2.1
|
|
18
|
+
end if (RUBY_PLATFORM != "java" || ENV["SPHINX_VERSION"].to_f > 2.1) && RUBY_VERSION.to_f < 3.0
|
|
19
19
|
|
|
20
20
|
appraise 'rails_5_1' do
|
|
21
21
|
gem 'rails', '~> 5.1.0'
|
|
22
22
|
gem 'mysql2', '~> 0.4.0', :platform => :ruby
|
|
23
|
-
end if RUBY_PLATFORM != 'java'
|
|
23
|
+
end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f < 3.0
|
|
24
24
|
|
|
25
25
|
appraise 'rails_5_2' do
|
|
26
26
|
gem 'rails', '~> 5.2.0'
|
|
27
27
|
gem 'mysql2', '~> 0.5.0', :platform => :ruby
|
|
28
28
|
gem 'pg', '~> 1.0', :platform => :ruby
|
|
29
|
-
end if RUBY_PLATFORM != 'java'
|
|
29
|
+
end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f < 3.0
|
|
30
30
|
|
|
31
31
|
appraise 'rails_6_0' do
|
|
32
32
|
gem 'rails', '~> 6.0.0'
|
|
33
33
|
gem 'mysql2', '~> 0.5.0', :platform => :ruby
|
|
34
34
|
gem 'pg', '~> 1.0', :platform => :ruby
|
|
35
35
|
end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f >= 2.5
|
|
36
|
+
|
|
37
|
+
appraise 'rails_6_1' do
|
|
38
|
+
gem 'rails', '~> 6.1.0'
|
|
39
|
+
gem 'mysql2', '~> 0.5.0', :platform => :ruby
|
|
40
|
+
gem 'pg', '~> 1.0', :platform => :ruby
|
|
41
|
+
end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f >= 2.5
|
data/CHANGELOG.markdown
CHANGED
|
@@ -2,6 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project (at least, from v3.0.0 onwards) are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 5.3.0 - 2021-08-19
|
|
6
|
+
|
|
7
|
+
[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.3.0)
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* StaleIdsExceptions now include a URL in their error message with recommendations on how to resolve the problem.
|
|
12
|
+
* Fire real-time callbacks on `after_commit` (including deletions) to ensure data is fully persisted to the database before updating Sphinx. More details in [#1204](https://github.com/pat/thinking-sphinx/pull/1204).
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
* Ensure Thinking Sphinx's ActiveRecord components are loaded by either Rails' after_initialise hook or ActiveSupport's on_load notification, because the order of these two events are not consistent.
|
|
17
|
+
* Remove `app/indices` from eager_load_paths in Rails 4.2 and 5, to match the behaviour in 6.
|
|
18
|
+
|
|
19
|
+
## 5.2.1 - 2021-08-09
|
|
20
|
+
|
|
21
|
+
[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.2.1)
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
* Ensure ActiveRecord components are loaded for rake tasks, but only after the Rails application has initialised. More details in [#1199](https://github.com/pat/thinking-sphinx/issues/1199).
|
|
26
|
+
|
|
27
|
+
## 5.2.0 - 2021-06-12
|
|
28
|
+
|
|
29
|
+
[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.2.0)
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
* Confirmed support for Ruby 3.0.
|
|
34
|
+
* Orphaned records in real-time indices can now be cleaned up without running `rails ts:rebuild`. Disabled by default, can be enabled by setting `real_time_tidy` to true per environment in `config/thinking_sphinx.yml` (and will need `ts:rebuild` to restructure indices upon initial deploy). More details in [#1192](https://github.com/pat/thinking-sphinx/pull/1192).
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
* Avoid loading ActiveRecord during Rails initialisation so app configuration can still have an impact ([@jdelStrother](https://github.com/jdelStrother) in [#1194](https://github.com/pat/thinking-sphinx/pull/1194)).
|
|
39
|
+
* Remove `app/indices` (in both the Rails app and engines) from Rails' eager load paths, which was otherwise leading to indices being loaded more than once. (See [#1191](https://github.com/pat/thinking-sphinx/issues/1191) and [#1195](https://github.com/pat/thinking-sphinx/issues/1195)).
|
|
40
|
+
|
|
41
|
+
## 5.1.0 - 2020-12-28
|
|
42
|
+
|
|
43
|
+
[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.1.0)
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
* Support for Sphinx v3.3 and Manticore v3.5.
|
|
48
|
+
* Support for Rails 6.1 (via [joiner](https://rubygems.org/gems/joiner) v0.6.0).
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
* `enable_star` is no longer available as a configuration option, as it's been enabled by default in Sphinx since v2.2.2, and is no longer allowed in Sphinx v3.3.1.
|
|
53
|
+
* All timestamp attributes are now considered plain integer values from Sphinx's perspective. Sphinx was already expecting integers, but since Sphinx v3.3.1 it doesn't recognise timestamps as a data type. There is no functional difference with this change - Thinking Sphinx was always converting times to their UNIX epoch integer values.
|
|
54
|
+
* Allow configuration of the maximum statement length ([@kalsan](https://github.com/kalsan) in [#1179](https://github.com/pat/thinking-sphinx/pull/1179)).
|
|
55
|
+
* Respect `:path` values to navigate associations for Thinking Sphinx callbacks on SQL-backed indices. Discussed in [#1182](https://github.com/pat/thinking-sphinx/issues/1182).
|
|
56
|
+
|
|
57
|
+
### Fixed
|
|
58
|
+
|
|
59
|
+
* Don't attempt to update delta flags on frozen model instances.
|
|
60
|
+
|
|
5
61
|
## 5.0.0 - 2020-07-20
|
|
6
62
|
|
|
7
63
|
[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.0.0)
|
|
@@ -20,7 +76,7 @@ All notable changes to this project (at least, from v3.0.0 onwards) are document
|
|
|
20
76
|
* Remove internal uses of `send`, replaced with `public_send` as that's available in all supported Ruby versions.
|
|
21
77
|
* Deletion statements are simplified by avoiding the need to calculate document keys/offsets (@njakobsen via [#1134](https://github.com/pat/thinking-sphinx/issues/1134)).
|
|
22
78
|
* Real-time data is deleted before replacing it, to avoid duplicate data when offsets change (@njakobsen via [#1134](https://github.com/pat/thinking-sphinx/issues/1134)).
|
|
23
|
-
* Use `reference_name` as per custom `index_set_class` definitions. Previously, the class method was called on `ThinkingSphinx::IndexSet` even if a custom subclass was configured. (As per
|
|
79
|
+
* Use `reference_name` as per custom `index_set_class` definitions. Previously, the class method was called on `ThinkingSphinx::IndexSet` even if a custom subclass was configured. (As per discussions with @kalsan in [#1172](https://github.com/pat/thinking-sphinx/issues/1172).)
|
|
24
80
|
|
|
25
81
|
## 4.4.1 - 2019-08-23
|
|
26
82
|
|
data/README.textile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 v5.
|
|
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 v5.3.0.
|
|
4
4
|
|
|
5
5
|
h2. Upgrading
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ It's a gem, so install it like you would any other gem. You will also need to sp
|
|
|
14
14
|
|
|
15
15
|
<pre><code>gem 'mysql2', '~> 0.4', :platform => :ruby
|
|
16
16
|
gem 'jdbc-mysql', '~> 5.1.35', :platform => :jruby
|
|
17
|
-
gem 'thinking-sphinx', '~> 5.
|
|
17
|
+
gem 'thinking-sphinx', '~> 5.3'</code></pre>
|
|
18
18
|
|
|
19
19
|
The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database.
|
|
20
20
|
|
|
@@ -29,18 +29,18 @@ h2. Requirements
|
|
|
29
29
|
The current release of Thinking Sphinx works with the following versions of its dependencies:
|
|
30
30
|
|
|
31
31
|
|_. Library |_. Minimum |_. Tested Against |
|
|
32
|
-
| Ruby | v2.4 | v2.4, v2.5, v2.6, v2.7 |
|
|
33
|
-
| Sphinx | v2.2.11 | v2.2.11, v3.
|
|
34
|
-
| Manticore | v2.8 | v2.8, v3.
|
|
35
|
-
| ActiveRecord | v4.2 | v4.2..v6.
|
|
32
|
+
| Ruby | v2.4 | v2.4, v2.5, v2.6, v2.7, v3.0 |
|
|
33
|
+
| Sphinx | v2.2.11 | v2.2.11, v3.3.1 |
|
|
34
|
+
| Manticore | v2.8 | v2.8, v3.5 |
|
|
35
|
+
| ActiveRecord | v4.2 | v4.2..v6.1 |
|
|
36
36
|
|
|
37
37
|
It _might_ work with older versions of Ruby, but it's highly recommended to update to a supported release.
|
|
38
38
|
|
|
39
|
-
It should also work with JRuby, but the test environment
|
|
39
|
+
It should also work with JRuby, but the test environment for that in CI has been unreliable, hence that's not actively tested against at the moment.
|
|
40
40
|
|
|
41
41
|
h3. Sphinx or Manticore
|
|
42
42
|
|
|
43
|
-
Thinking Sphinx is currently built for Sphinx 2.2.11 or newer
|
|
43
|
+
Thinking Sphinx is currently built for Sphinx 2.2.11 or newer, or Manticore v2.8+.
|
|
44
44
|
|
|
45
45
|
h3. Rails and ActiveRecord
|
|
46
46
|
|
data/bin/loadsphinx
CHANGED
|
@@ -14,7 +14,7 @@ load_sphinx () {
|
|
|
14
14
|
format="deb"
|
|
15
15
|
distro="trusty";;
|
|
16
16
|
2.2.11)
|
|
17
|
-
url="http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~
|
|
17
|
+
url="http://sphinxsearch.com/files/sphinxsearch_2.2.11-release-1~jessie_amd64.deb"
|
|
18
18
|
format="deb";;
|
|
19
19
|
3.0.3)
|
|
20
20
|
url="http://sphinxsearch.com/files/sphinx-3.0.3-facc3fb-linux-amd64.tar.gz"
|
|
@@ -23,7 +23,10 @@ load_sphinx () {
|
|
|
23
23
|
url="http://sphinxsearch.com/files/sphinx-3.1.1-612d99f-linux-amd64.tar.gz"
|
|
24
24
|
format="gz";;
|
|
25
25
|
3.2.1)
|
|
26
|
-
url="http://
|
|
26
|
+
url="http://sphinxsearch.com/files/sphinx-3.2.1-f152e0b-linux-amd64.tar.gz"
|
|
27
|
+
format="gz";;
|
|
28
|
+
3.3.1)
|
|
29
|
+
url="http://sphinxsearch.com/files/sphinx-3.3.1-b72d67b-linux-amd64.tar.gz"
|
|
27
30
|
format="gz";;
|
|
28
31
|
*)
|
|
29
32
|
echo "No Sphinx version $version available"
|
|
@@ -37,7 +40,9 @@ load_sphinx () {
|
|
|
37
40
|
|
|
38
41
|
if [ "$format" == "deb" ]; then
|
|
39
42
|
curl --location $url -o sphinx.deb
|
|
40
|
-
sudo apt-get install
|
|
43
|
+
sudo apt-get install libodbc1
|
|
44
|
+
sudo dpkg -i ./sphinx.deb
|
|
45
|
+
sudo apt-get install -f
|
|
41
46
|
else
|
|
42
47
|
curl $url -o sphinx.tar.gz
|
|
43
48
|
tar -zxvf sphinx.tar.gz
|
|
@@ -54,16 +59,19 @@ load_manticore () {
|
|
|
54
59
|
2.7.5)
|
|
55
60
|
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.7.5/manticore_2.7.5-181204-4a31c54-release-stemmer.xenial_amd64-bin.deb";;
|
|
56
61
|
2.8.2)
|
|
57
|
-
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.8.2/manticore_2.8.2-190402-
|
|
62
|
+
url="https://github.com/manticoresoftware/manticoresearch/releases/download/2.8.2/manticore_2.8.2-190402-4e81114d-release-stemmer.stretch_amd64-bin.deb";;
|
|
58
63
|
3.4.2)
|
|
59
64
|
url="https://github.com/manticoresoftware/manticoresearch/releases/download/3.4.2/manticore_3.4.2-200410-6903305-release.xenial_amd64-bin.deb";;
|
|
65
|
+
3.5.4)
|
|
66
|
+
url="https://repo.manticoresearch.com/repository/manticoresearch_buster/pool/m/manticore/manticore_3.5.4-201211-13f8d08d_amd64.deb";;
|
|
60
67
|
*)
|
|
61
68
|
echo "No Manticore version $version available"
|
|
62
69
|
exit 1;;
|
|
63
70
|
esac
|
|
64
71
|
|
|
65
72
|
curl --location $url -o manticore.deb
|
|
66
|
-
sudo
|
|
73
|
+
sudo dpkg -i ./manticore.deb
|
|
74
|
+
sudo apt-get install -f
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
if [ "$engine" == "sphinx" ]; then
|
data/lib/thinking_sphinx.rb
CHANGED
|
@@ -17,8 +17,6 @@ require 'active_support/core_ext/module/delegation'
|
|
|
17
17
|
require 'active_support/core_ext/module/attribute_accessors'
|
|
18
18
|
|
|
19
19
|
module ThinkingSphinx
|
|
20
|
-
MAXIMUM_STATEMENT_LENGTH = (2 ** 23) - 5
|
|
21
|
-
|
|
22
20
|
def self.count(query = '', options = {})
|
|
23
21
|
search_for_ids(query, options).total_entries
|
|
24
22
|
end
|
|
@@ -98,7 +96,6 @@ require 'thinking_sphinx/test'
|
|
|
98
96
|
require 'thinking_sphinx/utf8'
|
|
99
97
|
require 'thinking_sphinx/wildcard'
|
|
100
98
|
# Extended
|
|
101
|
-
require 'thinking_sphinx/active_record'
|
|
102
99
|
require 'thinking_sphinx/deltas'
|
|
103
100
|
require 'thinking_sphinx/distributed'
|
|
104
101
|
require 'thinking_sphinx/logger'
|
|
@@ -29,6 +29,7 @@ require 'thinking_sphinx/active_record/source_joins'
|
|
|
29
29
|
require 'thinking_sphinx/active_record/sql_builder'
|
|
30
30
|
require 'thinking_sphinx/active_record/sql_source'
|
|
31
31
|
|
|
32
|
+
require 'thinking_sphinx/active_record/callbacks/association_delta_callbacks'
|
|
32
33
|
require 'thinking_sphinx/active_record/callbacks/delete_callbacks'
|
|
33
34
|
require 'thinking_sphinx/active_record/callbacks/delta_callbacks'
|
|
34
35
|
require 'thinking_sphinx/active_record/callbacks/update_callbacks'
|
|
@@ -39,3 +40,5 @@ require 'thinking_sphinx/active_record/depolymorph/conditions_reflection'
|
|
|
39
40
|
require 'thinking_sphinx/active_record/depolymorph/overridden_reflection'
|
|
40
41
|
require 'thinking_sphinx/active_record/depolymorph/scoped_reflection'
|
|
41
42
|
require 'thinking_sphinx/active_record/filter_reflection'
|
|
43
|
+
|
|
44
|
+
ActiveRecord::Base.include ThinkingSphinx::ActiveRecord::Base
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class ThinkingSphinx::ActiveRecord::Callbacks::AssociationDeltaCallbacks
|
|
4
|
+
def initialize(path)
|
|
5
|
+
@path = path
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def after_commit(instance)
|
|
9
|
+
Array(objects_for(instance)).each do |object|
|
|
10
|
+
object.update :delta => true unless object.frozen?
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
attr_reader :path
|
|
17
|
+
|
|
18
|
+
def objects_for(instance)
|
|
19
|
+
path.inject(instance) { |object, method| object.send method }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
class ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks <
|
|
4
4
|
ThinkingSphinx::Callbacks
|
|
5
5
|
|
|
6
|
-
callbacks :after_destroy, :after_rollback
|
|
6
|
+
callbacks :after_commit, :after_destroy, :after_rollback
|
|
7
|
+
|
|
8
|
+
def after_commit
|
|
9
|
+
delete_from_sphinx
|
|
10
|
+
end
|
|
7
11
|
|
|
8
12
|
def after_destroy
|
|
9
13
|
delete_from_sphinx
|
|
@@ -13,29 +13,45 @@ class ThinkingSphinx::Callbacks::Appender
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def call
|
|
16
|
-
|
|
16
|
+
add_core_callbacks
|
|
17
|
+
add_delta_callbacks if behaviours.include?(:deltas)
|
|
18
|
+
add_real_time_callbacks if behaviours.include?(:real_time)
|
|
19
|
+
add_update_callbacks if behaviours.include?(:updates)
|
|
20
|
+
end
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
model.before_save ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks
|
|
20
|
-
model.after_commit ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks
|
|
21
|
-
end
|
|
22
|
+
private
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
model.after_save ThinkingSphinx::RealTime.callback_for(
|
|
25
|
-
reference, path, &block
|
|
26
|
-
)
|
|
27
|
-
end
|
|
24
|
+
attr_reader :model, :reference, :options, :block
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
def add_core_callbacks
|
|
27
|
+
model.after_commit(
|
|
28
|
+
ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks,
|
|
29
|
+
on: :destroy
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def add_delta_callbacks
|
|
34
|
+
if path.empty?
|
|
35
|
+
model.before_save ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks
|
|
36
|
+
model.after_commit ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks
|
|
37
|
+
else
|
|
38
|
+
model.after_commit(
|
|
39
|
+
ThinkingSphinx::ActiveRecord::Callbacks::AssociationDeltaCallbacks
|
|
40
|
+
.new(path)
|
|
32
41
|
)
|
|
33
42
|
end
|
|
34
43
|
end
|
|
35
44
|
|
|
36
|
-
|
|
45
|
+
def add_real_time_callbacks
|
|
46
|
+
model.after_commit(
|
|
47
|
+
ThinkingSphinx::RealTime.callback_for(reference, path, &block),
|
|
48
|
+
on: [:create, :update]
|
|
49
|
+
)
|
|
50
|
+
end
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
def add_update_callbacks
|
|
53
|
+
model.after_update ThinkingSphinx::ActiveRecord::Callbacks::UpdateCallbacks
|
|
54
|
+
end
|
|
39
55
|
|
|
40
56
|
def behaviours
|
|
41
57
|
options[:behaviours] || []
|
|
@@ -39,7 +39,7 @@ class ThinkingSphinx::Connection::Client
|
|
|
39
39
|
private
|
|
40
40
|
|
|
41
41
|
def check(statements)
|
|
42
|
-
if statements.length >
|
|
42
|
+
if statements.length > maximum_statement_length
|
|
43
43
|
exception = ThinkingSphinx::QueryLengthError.new
|
|
44
44
|
exception.statement = statements
|
|
45
45
|
raise exception
|
|
@@ -56,6 +56,11 @@ class ThinkingSphinx::Connection::Client
|
|
|
56
56
|
@client = nil
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
def maximum_statement_length
|
|
60
|
+
@maximum_statement_length ||= ThinkingSphinx::Configuration.instance.
|
|
61
|
+
settings['maximum_statement_length']
|
|
62
|
+
end
|
|
63
|
+
|
|
59
64
|
def perform(statements)
|
|
60
65
|
results_for statements
|
|
61
66
|
rescue => error
|
|
@@ -38,7 +38,7 @@ end
|
|
|
38
38
|
class ThinkingSphinx::QueryLengthError < ThinkingSphinx::SphinxError
|
|
39
39
|
def message
|
|
40
40
|
<<-MESSAGE
|
|
41
|
-
The supplied SphinxQL statement is #{statement.length} characters long. The maximum allowed length is #{ThinkingSphinx::
|
|
41
|
+
The supplied SphinxQL statement is #{statement.length} characters long. The maximum allowed length is #{ThinkingSphinx::Configuration.instance.settings['maximum_statement_length']}.
|
|
42
42
|
|
|
43
43
|
If this error has been raised during real-time index population, it's probably due to overly large batches of records being processed at once. The default is 1000, but you can lower it on a per-environment basis in config/thinking_sphinx.yml:
|
|
44
44
|
|
|
@@ -5,18 +5,25 @@ class ThinkingSphinx::Railtie < Rails::Railtie
|
|
|
5
5
|
ThinkingSphinx::Configuration.reset
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
+
config.after_initialize do
|
|
9
|
+
require 'thinking_sphinx/active_record'
|
|
10
|
+
end
|
|
11
|
+
|
|
8
12
|
initializer 'thinking_sphinx.initialisation' do
|
|
9
13
|
ActiveSupport.on_load(:active_record) do
|
|
10
|
-
|
|
14
|
+
require 'thinking_sphinx/active_record'
|
|
11
15
|
end
|
|
12
16
|
|
|
13
|
-
if ActiveSupport::VERSION::MAJOR > 5
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
17
|
+
if ActiveSupport::VERSION::MAJOR > 5 &&
|
|
18
|
+
Rails.application.config.autoloader == :zeitwerk
|
|
19
|
+
ActiveSupport::Dependencies.autoload_paths.delete(
|
|
20
|
+
Rails.root.join("app", "indices").to_s
|
|
21
|
+
)
|
|
19
22
|
end
|
|
23
|
+
|
|
24
|
+
Rails.application.config.eager_load_paths -=
|
|
25
|
+
ThinkingSphinx::Configuration.instance.index_paths
|
|
26
|
+
Rails.application.config.eager_load_paths.freeze
|
|
20
27
|
end
|
|
21
28
|
|
|
22
29
|
rake_tasks do
|
|
@@ -65,12 +65,10 @@ class ThinkingSphinx::RealTime::Index < Riddle::Configuration::RealtimeIndex
|
|
|
65
65
|
|
|
66
66
|
def collection_for(attribute)
|
|
67
67
|
case attribute.type
|
|
68
|
-
when :integer, :boolean
|
|
68
|
+
when :integer, :boolean, :timestamp
|
|
69
69
|
attribute.multi? ? @rt_attr_multi : @rt_attr_uint
|
|
70
70
|
when :string
|
|
71
71
|
@rt_attr_string
|
|
72
|
-
when :timestamp
|
|
73
|
-
@rt_attr_timestamp
|
|
74
72
|
when :float
|
|
75
73
|
@rt_attr_float
|
|
76
74
|
when :bigint
|
|
@@ -13,6 +13,10 @@ class ThinkingSphinx::RealTime::Index::Template
|
|
|
13
13
|
add_attribute primary_key, :sphinx_internal_id, :bigint
|
|
14
14
|
add_attribute class_column, :sphinx_internal_class, :string, :facet => true
|
|
15
15
|
add_attribute 0, :sphinx_deleted, :integer
|
|
16
|
+
|
|
17
|
+
if tidying?
|
|
18
|
+
add_attribute -> (_) { Time.current.to_i }, :sphinx_updated_at, :timestamp
|
|
19
|
+
end
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
private
|
|
@@ -34,7 +38,15 @@ class ThinkingSphinx::RealTime::Index::Template
|
|
|
34
38
|
[:class, :name]
|
|
35
39
|
end
|
|
36
40
|
|
|
41
|
+
def config
|
|
42
|
+
ThinkingSphinx::Configuration.instance
|
|
43
|
+
end
|
|
44
|
+
|
|
37
45
|
def primary_key
|
|
38
46
|
index.primary_key.to_sym
|
|
39
47
|
end
|
|
48
|
+
|
|
49
|
+
def tidying?
|
|
50
|
+
config.settings["real_time_tidy"]
|
|
51
|
+
end
|
|
40
52
|
end
|
|
@@ -7,6 +7,7 @@ class ThinkingSphinx::RealTime::Populator
|
|
|
7
7
|
|
|
8
8
|
def initialize(index)
|
|
9
9
|
@index = index
|
|
10
|
+
@started_at = Time.current
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def populate
|
|
@@ -17,12 +18,14 @@ class ThinkingSphinx::RealTime::Populator
|
|
|
17
18
|
instrument 'populated', :instances => instances
|
|
18
19
|
end
|
|
19
20
|
|
|
21
|
+
transcriber.clear_before(started_at) if configuration.settings["real_time_tidy"]
|
|
22
|
+
|
|
20
23
|
instrument 'finish_populating'
|
|
21
24
|
end
|
|
22
25
|
|
|
23
26
|
private
|
|
24
27
|
|
|
25
|
-
attr_reader :index
|
|
28
|
+
attr_reader :index, :started_at
|
|
26
29
|
|
|
27
30
|
delegate :controller, :batch_size, :to => :configuration
|
|
28
31
|
delegate :scope, :to => :index
|
|
@@ -5,6 +5,12 @@ class ThinkingSphinx::RealTime::Transcriber
|
|
|
5
5
|
@index = index
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
+
def clear_before(time)
|
|
9
|
+
execute <<~SQL.strip
|
|
10
|
+
DELETE FROM #{@index.name} WHERE sphinx_updated_at < #{time.to_i}
|
|
11
|
+
SQL
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
def copy(*instances)
|
|
9
15
|
items = instances.select { |instance|
|
|
10
16
|
instance.persisted? && copy?(instance)
|
|
@@ -9,6 +9,7 @@ class ThinkingSphinx::Search::StaleIdsException < StandardError
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def message
|
|
12
|
-
"Record IDs found by Sphinx but not by ActiveRecord : #{ids.join(', ')}"
|
|
12
|
+
"Record IDs found by Sphinx but not by ActiveRecord : #{ids.join(', ')}\n" \
|
|
13
|
+
"https://freelancing-gods.com/thinking-sphinx/v5/common_issues.html#record-ids"
|
|
13
14
|
end
|
|
14
15
|
end
|
|
@@ -11,14 +11,16 @@ class ThinkingSphinx::Settings
|
|
|
11
11
|
lemmatizer_base mysql_ssl_cert mysql_ssl_key mysql_ssl_ca
|
|
12
12
|
].freeze
|
|
13
13
|
DEFAULTS = {
|
|
14
|
-
"configuration_file"
|
|
15
|
-
"indices_location"
|
|
16
|
-
"pid_file"
|
|
17
|
-
"log"
|
|
18
|
-
"query_log"
|
|
19
|
-
"binlog_path"
|
|
20
|
-
"workers"
|
|
21
|
-
"mysql_encoding"
|
|
14
|
+
"configuration_file" => "config/ENVIRONMENT.sphinx.conf",
|
|
15
|
+
"indices_location" => "db/sphinx/ENVIRONMENT",
|
|
16
|
+
"pid_file" => "log/ENVIRONMENT.sphinx.pid",
|
|
17
|
+
"log" => "log/ENVIRONMENT.searchd.log",
|
|
18
|
+
"query_log" => "log/ENVIRONMENT.searchd.query.log",
|
|
19
|
+
"binlog_path" => "tmp/binlog/ENVIRONMENT",
|
|
20
|
+
"workers" => "threads",
|
|
21
|
+
"mysql_encoding" => "utf8",
|
|
22
|
+
"maximum_statement_length" => (2 ** 23) - 5,
|
|
23
|
+
"real_time_tidy" => false
|
|
22
24
|
}.freeze
|
|
23
25
|
|
|
24
26
|
def self.call(configuration)
|
|
@@ -62,7 +64,9 @@ class ThinkingSphinx::Settings
|
|
|
62
64
|
|
|
63
65
|
def defaults
|
|
64
66
|
DEFAULTS.inject({}) do |hash, (key, value)|
|
|
65
|
-
|
|
67
|
+
if value.is_a?(String)
|
|
68
|
+
value = value.gsub("ENVIRONMENT", framework.environment)
|
|
69
|
+
end
|
|
66
70
|
|
|
67
71
|
if FILE_KEYS.include?(key)
|
|
68
72
|
hash[key] = absolute value
|
|
@@ -38,10 +38,20 @@ describe 'Searching by latitude and longitude', :live => true do
|
|
|
38
38
|
expected = {:mysql => 250326.906250, :postgresql => 250331.234375}
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
adapter = nil
|
|
42
|
+
|
|
43
|
+
if ActiveRecord::VERSION::STRING.to_f > 6.0
|
|
44
|
+
adapter = ActiveRecord::Base.configurations.configs_for.first.adapter
|
|
45
|
+
elsif ActiveRecord::VERSION::STRING.to_f > 5.2
|
|
46
|
+
adapter = ActiveRecord::Base.configurations.configs_for.first.config["adapter"]
|
|
47
|
+
else
|
|
48
|
+
adapter = ActiveRecord::Base.configurations['test']['adapter']
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
if adapter[/postgres/]
|
|
52
|
+
expect(cities.first.geodist).to be_within(0.01).of(expected[:postgresql])
|
|
43
53
|
else # mysql
|
|
44
|
-
expect(cities.first.geodist).to
|
|
54
|
+
expect(cities.first.geodist).to be_within(0.01).of(expected[:mysql])
|
|
45
55
|
end
|
|
46
56
|
end
|
|
47
57
|
|
|
@@ -16,7 +16,7 @@ describe 'SQL delta indexing', :live => true do
|
|
|
16
16
|
)
|
|
17
17
|
sleep 0.25
|
|
18
18
|
|
|
19
|
-
expect(Book.search('Terry Pratchett').to_a).to
|
|
19
|
+
expect(Book.search('Terry Pratchett').to_a).to match_array([guards, men])
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "automatically indexes updated records" do
|
|
@@ -63,4 +63,16 @@ describe 'SQL delta indexing', :live => true do
|
|
|
63
63
|
|
|
64
64
|
expect(Book.search('Gaiman').to_a).to eq([book])
|
|
65
65
|
end
|
|
66
|
+
|
|
67
|
+
it "updates associated models" do
|
|
68
|
+
colour = Colour.create(:name => 'green')
|
|
69
|
+
sleep 0.25
|
|
70
|
+
|
|
71
|
+
expect(Colour.search('green').to_a).to eq([colour])
|
|
72
|
+
|
|
73
|
+
tee = colour.tees.create
|
|
74
|
+
sleep 0.25
|
|
75
|
+
|
|
76
|
+
expect(Colour.search(:with => {:tee_ids => tee.id}).to_a).to eq([colour])
|
|
77
|
+
end
|
|
66
78
|
end
|
|
@@ -6,22 +6,22 @@ module SphinxHelpers
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def index(*indices)
|
|
9
|
-
sleep 0.5 if ENV['
|
|
9
|
+
sleep 0.5 if ENV['CI']
|
|
10
10
|
|
|
11
11
|
yield if block_given?
|
|
12
12
|
|
|
13
13
|
sphinx.index *indices
|
|
14
14
|
sleep 0.25
|
|
15
|
-
sleep 0.5 if ENV['
|
|
15
|
+
sleep 0.5 if ENV['CI']
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def merge
|
|
19
|
-
sleep 0.5 if ENV['
|
|
19
|
+
sleep 0.5 if ENV['CI']
|
|
20
20
|
sleep 0.5
|
|
21
21
|
|
|
22
22
|
sphinx.merge
|
|
23
23
|
sleep 1.5
|
|
24
|
-
sleep 0.5 if ENV['
|
|
24
|
+
sleep 0.5 if ENV['CI']
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -10,7 +10,6 @@ ThinkingSphinx::Index.define :article, :with => :active_record do
|
|
|
10
10
|
has taggings.created_at, :as => :taggings_at, :type => :timestamp
|
|
11
11
|
|
|
12
12
|
set_property :min_infix_len => 4
|
|
13
|
-
set_property :enable_star => true
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
ThinkingSphinx::Index.define :article, :with => :active_record,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
test:
|
|
2
2
|
adapter: <%= ENV['DATABASE'] || 'mysql2' %>
|
|
3
3
|
database: thinking_sphinx
|
|
4
|
-
username: <%= ENV['DATABASE'] == 'postgresql' ?
|
|
4
|
+
username: <%= ENV['DATABASE'] == 'postgresql' ? 'postgres' : 'root' %>
|
|
5
|
+
<% if ENV["CI"] %>
|
|
6
|
+
password: thinking_sphinx
|
|
7
|
+
host: 127.0.0.1
|
|
8
|
+
port: <%= ENV['DATABASE'] == 'postgresql' ? 5432 : 3306 %>
|
|
9
|
+
<% end %>
|
|
5
10
|
min_messages: warning
|
|
6
11
|
encoding: utf8
|
data/spec/internal/db/schema.rb
CHANGED
|
@@ -5,7 +5,9 @@ require 'spec_helper'
|
|
|
5
5
|
describe ThinkingSphinx::ActiveRecord::Index do
|
|
6
6
|
let(:index) { ThinkingSphinx::ActiveRecord::Index.new :user }
|
|
7
7
|
let(:config) { double('config', :settings => {},
|
|
8
|
-
:indices_location => 'location', :next_offset => 8
|
|
8
|
+
:indices_location => 'location', :next_offset => 8,
|
|
9
|
+
:index_set_class => index_set_class) }
|
|
10
|
+
let(:index_set_class) { double :reference_name => :user }
|
|
9
11
|
|
|
10
12
|
before :each do
|
|
11
13
|
allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
|
|
@@ -325,14 +325,14 @@ describe ThinkingSphinx::ActiveRecord::SQLSource do
|
|
|
325
325
|
expect(source.sql_attr_string).to include('name')
|
|
326
326
|
end
|
|
327
327
|
|
|
328
|
-
it "adds timestamp attributes to
|
|
328
|
+
it "adds timestamp attributes to sql_attr_uint" do
|
|
329
329
|
source.attributes << double('attribute')
|
|
330
330
|
allow(presenter).to receive_messages :declaration => 'created_at',
|
|
331
|
-
:collection_type => :
|
|
331
|
+
:collection_type => :uint
|
|
332
332
|
|
|
333
333
|
source.render
|
|
334
334
|
|
|
335
|
-
expect(source.
|
|
335
|
+
expect(source.sql_attr_uint).to include('created_at')
|
|
336
336
|
end
|
|
337
337
|
|
|
338
338
|
it "adds float attributes to sql_attr_float" do
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe ThinkingSphinx::Connection::MRI do
|
|
4
|
+
subject { described_class.new :host => "127.0.0.1", :port => 9306 }
|
|
5
|
+
|
|
6
|
+
let(:client) { double :client, :query => "result", :next_result => false }
|
|
7
|
+
|
|
8
|
+
before :each do
|
|
9
|
+
allow(Mysql2::Client).to receive(:new).and_return(client)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
after :each do
|
|
13
|
+
ThinkingSphinx::Configuration.reset
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#execute" do
|
|
17
|
+
it "sends the query to the client" do
|
|
18
|
+
subject.execute "SELECT QUERY"
|
|
19
|
+
|
|
20
|
+
expect(client).to have_received(:query).with("SELECT QUERY")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "returns a result" do
|
|
24
|
+
expect(subject.execute("SELECT QUERY")).to eq("result")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context "with long queries" do
|
|
28
|
+
let(:maximum) { (2 ** 23) - 5 }
|
|
29
|
+
let(:query) { String.new "SELECT * FROM book_core WHERE MATCH('')" }
|
|
30
|
+
let(:difference) { maximum - query.length }
|
|
31
|
+
|
|
32
|
+
it 'does not allow overly long queries' do
|
|
33
|
+
expect {
|
|
34
|
+
subject.execute(query.insert(-3, 'a' * (difference + 5)))
|
|
35
|
+
}.to raise_error(ThinkingSphinx::QueryLengthError)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'does not allow queries longer than specified in the settings' do
|
|
39
|
+
ThinkingSphinx::Configuration.reset
|
|
40
|
+
|
|
41
|
+
write_configuration('maximum_statement_length' => maximum - 5)
|
|
42
|
+
|
|
43
|
+
expect {
|
|
44
|
+
subject.execute(query.insert(-3, 'a' * (difference)))
|
|
45
|
+
}.to raise_error(ThinkingSphinx::QueryLengthError)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end if RUBY_PLATFORM != 'java'
|
|
@@ -5,7 +5,9 @@ require 'spec_helper'
|
|
|
5
5
|
describe ThinkingSphinx::RealTime::Index do
|
|
6
6
|
let(:index) { ThinkingSphinx::RealTime::Index.new :user }
|
|
7
7
|
let(:config) { double('config', :settings => {},
|
|
8
|
-
:indices_location => 'location', :next_offset => 8
|
|
8
|
+
:indices_location => 'location', :next_offset => 8,
|
|
9
|
+
:index_set_class => index_set_class) }
|
|
10
|
+
let(:index_set_class) { double(:index_set_class, :reference_name => :user) }
|
|
9
11
|
|
|
10
12
|
before :each do
|
|
11
13
|
allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
|
|
@@ -61,6 +63,16 @@ describe ThinkingSphinx::RealTime::Index do
|
|
|
61
63
|
it "has the internal deleted attribute by default" do
|
|
62
64
|
expect(index.attributes.collect(&:name)).to include('sphinx_deleted')
|
|
63
65
|
end
|
|
66
|
+
|
|
67
|
+
it "does not have an internal updated_at attribute by default" do
|
|
68
|
+
expect(index.attributes.collect(&:name)).to_not include('sphinx_updated_at')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "has an internal updated_at attribute if real_time_tidy is true" do
|
|
72
|
+
config.settings["real_time_tidy"] = true
|
|
73
|
+
|
|
74
|
+
expect(index.attributes.collect(&:name)).to include('sphinx_updated_at')
|
|
75
|
+
end
|
|
64
76
|
end
|
|
65
77
|
|
|
66
78
|
describe '#delta?' do
|
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: 5.
|
|
4
|
+
version: 5.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pat Allan
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-08-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -174,6 +174,7 @@ executables:
|
|
|
174
174
|
extensions: []
|
|
175
175
|
extra_rdoc_files: []
|
|
176
176
|
files:
|
|
177
|
+
- ".circleci/config.yml"
|
|
177
178
|
- ".gitignore"
|
|
178
179
|
- ".travis.yml"
|
|
179
180
|
- Appraisals
|
|
@@ -197,6 +198,7 @@ files:
|
|
|
197
198
|
- lib/thinking_sphinx/active_record/attribute/type.rb
|
|
198
199
|
- lib/thinking_sphinx/active_record/attribute/values.rb
|
|
199
200
|
- lib/thinking_sphinx/active_record/base.rb
|
|
201
|
+
- lib/thinking_sphinx/active_record/callbacks/association_delta_callbacks.rb
|
|
200
202
|
- lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb
|
|
201
203
|
- lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb
|
|
202
204
|
- lib/thinking_sphinx/active_record/callbacks/update_callbacks.rb
|
|
@@ -356,7 +358,6 @@ files:
|
|
|
356
358
|
- spec/acceptance/attribute_updates_spec.rb
|
|
357
359
|
- spec/acceptance/batch_searching_spec.rb
|
|
358
360
|
- spec/acceptance/big_integers_spec.rb
|
|
359
|
-
- spec/acceptance/connection_spec.rb
|
|
360
361
|
- spec/acceptance/excerpts_spec.rb
|
|
361
362
|
- spec/acceptance/facets_spec.rb
|
|
362
363
|
- spec/acceptance/geosearching_spec.rb
|
|
@@ -393,6 +394,7 @@ files:
|
|
|
393
394
|
- spec/internal/app/indices/book_index.rb
|
|
394
395
|
- spec/internal/app/indices/car_index.rb
|
|
395
396
|
- spec/internal/app/indices/city_index.rb
|
|
397
|
+
- spec/internal/app/indices/colour_index.rb
|
|
396
398
|
- spec/internal/app/indices/product_index.rb
|
|
397
399
|
- spec/internal/app/indices/tee_index.rb
|
|
398
400
|
- spec/internal/app/indices/user_index.rb
|
|
@@ -461,6 +463,7 @@ files:
|
|
|
461
463
|
- spec/thinking_sphinx/commands/stop_spec.rb
|
|
462
464
|
- spec/thinking_sphinx/configuration/minimum_fields_spec.rb
|
|
463
465
|
- spec/thinking_sphinx/configuration_spec.rb
|
|
466
|
+
- spec/thinking_sphinx/connection/mri_spec.rb
|
|
464
467
|
- spec/thinking_sphinx/connection_spec.rb
|
|
465
468
|
- spec/thinking_sphinx/deletion_spec.rb
|
|
466
469
|
- spec/thinking_sphinx/deltas/default_delta_spec.rb
|
|
@@ -508,7 +511,7 @@ homepage: https://pat.github.io/thinking-sphinx/
|
|
|
508
511
|
licenses:
|
|
509
512
|
- MIT
|
|
510
513
|
metadata: {}
|
|
511
|
-
post_install_message:
|
|
514
|
+
post_install_message:
|
|
512
515
|
rdoc_options: []
|
|
513
516
|
require_paths:
|
|
514
517
|
- lib
|
|
@@ -524,7 +527,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
524
527
|
version: '0'
|
|
525
528
|
requirements: []
|
|
526
529
|
rubygems_version: 3.0.3
|
|
527
|
-
signing_key:
|
|
530
|
+
signing_key:
|
|
528
531
|
specification_version: 4
|
|
529
532
|
summary: A smart wrapper over Sphinx for ActiveRecord
|
|
530
533
|
test_files:
|
|
@@ -533,7 +536,6 @@ test_files:
|
|
|
533
536
|
- spec/acceptance/attribute_updates_spec.rb
|
|
534
537
|
- spec/acceptance/batch_searching_spec.rb
|
|
535
538
|
- spec/acceptance/big_integers_spec.rb
|
|
536
|
-
- spec/acceptance/connection_spec.rb
|
|
537
539
|
- spec/acceptance/excerpts_spec.rb
|
|
538
540
|
- spec/acceptance/facets_spec.rb
|
|
539
541
|
- spec/acceptance/geosearching_spec.rb
|
|
@@ -570,6 +572,7 @@ test_files:
|
|
|
570
572
|
- spec/internal/app/indices/book_index.rb
|
|
571
573
|
- spec/internal/app/indices/car_index.rb
|
|
572
574
|
- spec/internal/app/indices/city_index.rb
|
|
575
|
+
- spec/internal/app/indices/colour_index.rb
|
|
573
576
|
- spec/internal/app/indices/product_index.rb
|
|
574
577
|
- spec/internal/app/indices/tee_index.rb
|
|
575
578
|
- spec/internal/app/indices/user_index.rb
|
|
@@ -638,6 +641,7 @@ test_files:
|
|
|
638
641
|
- spec/thinking_sphinx/commands/stop_spec.rb
|
|
639
642
|
- spec/thinking_sphinx/configuration/minimum_fields_spec.rb
|
|
640
643
|
- spec/thinking_sphinx/configuration_spec.rb
|
|
644
|
+
- spec/thinking_sphinx/connection/mri_spec.rb
|
|
641
645
|
- spec/thinking_sphinx/connection_spec.rb
|
|
642
646
|
- spec/thinking_sphinx/deletion_spec.rb
|
|
643
647
|
- spec/thinking_sphinx/deltas/default_delta_spec.rb
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'acceptance/spec_helper'
|
|
4
|
-
|
|
5
|
-
RSpec.describe 'Connections', :live => true do
|
|
6
|
-
let(:maximum) { (2 ** 23) - 5 }
|
|
7
|
-
let(:query) { String.new "SELECT * FROM book_core WHERE MATCH('')" }
|
|
8
|
-
let(:difference) { maximum - query.length }
|
|
9
|
-
|
|
10
|
-
it 'allows normal length queries through' do
|
|
11
|
-
expect {
|
|
12
|
-
ThinkingSphinx::Connection.take do |connection|
|
|
13
|
-
connection.execute query.insert(-3, 'a' * difference)
|
|
14
|
-
end
|
|
15
|
-
}.to_not raise_error
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'does not allow overly long queries' do
|
|
19
|
-
expect {
|
|
20
|
-
ThinkingSphinx::Connection.take do |connection|
|
|
21
|
-
connection.execute query.insert(-3, 'a' * (difference + 5))
|
|
22
|
-
end
|
|
23
|
-
}.to raise_error(ThinkingSphinx::QueryLengthError)
|
|
24
|
-
end
|
|
25
|
-
end
|