Skip to content

Commit

Permalink
Merge branch 'release/v3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Jan 11, 2014
2 parents 337c6ae + 2ca6d59 commit 4491f44
Show file tree
Hide file tree
Showing 86 changed files with 1,062 additions and 809 deletions.
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
language: ruby
rvm:
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.0
- jruby-19mode
before_install:
- gem update --system
- curl -O http://fs-packages.s3.amazonaws.com/fs-sphinx-2.0.6_x86_64_12.04.deb
- sudo dpkg -i fs-sphinx-2.0.6_x86_64_12.04.deb
- sudo apt-get install postgresql-server-dev-9.1 libmysql++-dev -y
- curl -O http://fs-packages.s3.amazonaws.com/fs-sphinx-2.0.9_x86_64_12.04.deb
- sudo dpkg -i fs-sphinx-2.0.9_x86_64_12.04.deb
- curl -O http://fs-packages.s3.amazonaws.com/fs-sphinx-2.1.4_x86_64_12.04.deb
- sudo dpkg -i fs-sphinx-2.1.4_x86_64_12.04.deb
before_script:
- "mysql -e 'create database thinking_sphinx;' > /dev/null"
- "psql -c 'create database thinking_sphinx;' -U postgres >/dev/null"
env:
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.0.6/bin/ SPHINX_VERSION=2.0.6
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.0.6/bin/ SPHINX_VERSION=2.0.6
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.0.9/bin/ SPHINX_VERSION=2.0.9
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.0.9/bin/ SPHINX_VERSION=2.0.9
- DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.1.4/bin/ SPHINX_VERSION=2.1.4
- DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.1.4/bin/ SPHINX_VERSION=2.1.4
gemfile:
- gemfiles/rails_3_1.gemfile
- gemfiles/rails_3_2.gemfile
- gemfiles/rails_4_0.gemfile
10 changes: 5 additions & 5 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
appraise 'rails_3_1' do
gem 'rails', '~> 3.1.0'
end

appraise 'rails_3_2' do
gem 'rails', '~> 3.2.0'
end

appraise 'rails_4_0' do
gem 'rails', '~> 4.0.0.rc1'
gem 'rails', '~> 4.0.2'
end

appraise 'rails_4_1' do
gem 'rails', '~> 4.1.0.beta1'
end
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://rubygems.org'
gemspec

gem 'mysql2', '~> 0.3.12b4', :platform => :ruby
gem 'pg', '~> 0.11.0', :platform => :ruby
gem 'pg', '~> 0.16.0', :platform => :ruby

gem 'activerecord-jdbcmysql-adapter', '~> 1.1.3', :platform => :jruby
gem 'activerecord-jdbcpostgresql-adapter', '~> 1.1.3', :platform => :jruby
gem 'activerecord-jdbcmysql-adapter', '~> 1.3.4', :platform => :jruby
gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3.4', :platform => :jruby
32 changes: 32 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
2014-01-11: 3.1.0
* [CHANGE] Updating Riddle requirement to >= 1.5.10.
* [CHANGE] Extracting join generation into its own gem: Joiner.
* [FEATURE] Support for Capistrano v3 (Alexander Tipugin).
* [FEATURE] JRuby support (with Sphinx 2.1 or newer).
* [CHANGE] Geodist calculation is now prepended to the SELECT statement, so it can be referred to by other dynamic attributes.
* [FIX] Indices will be detected in Rails engines upon configuration.
* [FEATURE] Support for Sphinx 2.2.x's HAVING and GROUP N BY SphinxQL options.
* [FEATURE] Adding max_predicted_time search option (Sphinx 2.2.x).
* [FEATURE] Wildcard/starring can be applied directly to strings using ThinkingSphinx::Query.wildcard('pancakes'), and escaping via ThinkingSphinx::Query.escape('pancakes').
* [CHANGE] Auto-wildcard/starring (via :star => true) now treats escaped characters as word separators.
* [FEATURE] Capistrano recipe now includes tasks for realtime indices.
* [CHANGE] Capistrano recipe no longer automatically adds thinking_sphinx:index and thinking_sphinx:start to be run after deploy:cold.
* [CHANGE] UTF-8 forced encoding is now disabled by default (in line with Sphinx 2.1.x).
* [CHANGE] Sphinx functions are now the default, instead of the legacy special variables (in line with Sphinx 2.1.x).
* [CHANGE] Rails 3.1 is no longer supported.
* [CHANGE] MRI 1.9.2 is no longer supported.
* [FIX] Destroy callbacks are ignored for non-persisted objects.
* [FEATURE] :group option within :sql options in a search call is passed through to the underlying ActiveRecord relation (Siarhei Hanchuk).
* [FIX] Blank STI values are converted to the parent class in Sphinx index data (Jonathan Greenberg).
* [CHANGE] Insist on at least * for SphinxQL SELECT statements.
* [FIX] Track indices on parent STI models when marking documents as deleted.
* [FEATURE] Persistent connections can be disabled if you wish.
* [FIX] Separate per_page/max_matches values are respected in facet searches (Timo Virkkala).
* [FIX] Don't split function calls when casting timestamps (Timo Virkalla).
* [FEATURE] Track what's being indexed, and don't double-up while indexing is running. Single indices (e.g. deltas) can be processed while a full index is happening, though.
* [FEATURE] Pass through :delta_options to delta processors (Timo Virkalla).
* [FEATURE] All delta records can have their core pairs marked as deleted after a suspended delta (use ThinkingSphinx::Deltas.suspend_and_update instead of ThinkingSphinx::Deltas.suspend).
* [CHANGE] Reset the delta column to true after core indexing is completed, instead of before, and don't filter out delta records from the core source.
* [FEATURE] Set custom database settings within the index definition, using the set_database method. A more sane approach with multiple databases.
* [CHANGE] Provide a distributed index per model that covers both core and delta indices.

2013-10-20: 3.0.6
* [FEATURE] Raise an error if no indices match the search criteria (Bryan Ricker).
* [FEATURE] skip_time_zone setting is now available per environment via config/thinking_sphinx.yml to avoid the sql_query_pre time zone command.
Expand Down
21 changes: 16 additions & 5 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
h1. Thinking Sphinx

Welcome to Thinking Sphinx version 3 - a complete rewrite from past versions, built for Rails 3.1 or newer only.
Welcome to Thinking Sphinx version 3 - a complete rewrite from past versions. TS v3.0.x will work with Rails 3.1-4.0, and TS v3.1.x will work with Rails 3.2 and newer.

h2. Installation

It's a gem, so install it like you would any other gem. You will also need to specify the Mysql2 gem as well (this is not an inbuilt dependency because JRuby, when supported, will need something different):
It's a gem, so install it like you would any other gem. You will also need to specify the mysql2 gem if you're using MRI, or jdbc-mysql if you're using JRuby:

<pre><code>gem 'mysql2', '0.3.13'
gem 'thinking-sphinx', '3.0.6'</code></pre>
<pre><code>gem 'mysql2', '0.3.13', :platform => :ruby
gem 'jdbc-mysql', '5.1.28', :platform => :jruby
gem 'thinking-sphinx', '3.1.0'</code></pre>

The mysql2 gem is required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database.
The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database.

As for Sphinx itself, you need to make sure it's compiled with MySQL support, even if you're using PostgreSQL as your database - which is normally the default, but Homebrew can be too smart sometimes. If that's your compiling tool of choice, make sure you install with the @--mysql@ flag:

Expand Down Expand Up @@ -238,6 +239,16 @@ h2. Contributing

You're brave! To contribute, clone this repository and have a good look through the specs - you'll notice the distinction between acceptance tests that actually use Sphinx and go through the full stack, and unit tests (everything else) which use liberal test doubles to ensure they're only testing the behaviour of the class in question. I've found this leads to far better code design.

In order to run the specs, you'll need to create a MySQL database named @thinking_sphinx@:
<pre><code># Fire up a MySQL console connection:
mysql -u root
# In that console, create the database:
CREATE DATABASE thinking_sphinx;</code></pre>

You can then run the unit tests with @rake spec:unit@, the acceptance tests with @rake spec:acceptance@, or all of the tests with just @rake@.

All development is done on the @develop@ branch; please base any pull requests off of that branch.

If you're still interested in helping evolve this, then write the tests and then the code to get them passing, and send through a pull request. No promises on merging anything, but we shall see!

For some ideas behind my current approach, have a look through @sketchpad.rb@ in the root of this project. If you can make sense of that, you're doing very well indeed.
Expand Down
3 changes: 2 additions & 1 deletion gemfiles/rails_3_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
source "https://rubygems.org"

gem "mysql2", "~> 0.3.12b4", :platform=>:ruby
gem "pg", "~> 0.11.0", :platform=>:ruby
gem "pg", "~> 0.16.0", :platform=>:ruby
gem "activerecord-jdbcmysql-adapter", "~> 1.1.3", :platform=>:jruby
gem "activerecord-jdbcpostgresql-adapter", "~> 1.1.3", :platform=>:jruby
gem "riddle", :git=>"git://github.com/pat/riddle.git", :branch=>"develop"
gem "rails", "~> 3.2.0"

gemspec :path=>"../"
5 changes: 3 additions & 2 deletions gemfiles/rails_4_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
source "https://rubygems.org"

gem "mysql2", "~> 0.3.12b4", :platform=>:ruby
gem "pg", "~> 0.11.0", :platform=>:ruby
gem "pg", "~> 0.16.0", :platform=>:ruby
gem "activerecord-jdbcmysql-adapter", "~> 1.1.3", :platform=>:jruby
gem "activerecord-jdbcpostgresql-adapter", "~> 1.1.3", :platform=>:jruby
gem "rails", "~> 4.0.0.rc1"
gem "riddle", :git=>"git://github.com/pat/riddle.git", :branch=>"develop"
gem "rails", "~> 4.0.2"

gemspec :path=>"../"
5 changes: 3 additions & 2 deletions gemfiles/rails_3_1.gemfile → gemfiles/rails_4_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
source "https://rubygems.org"

gem "mysql2", "~> 0.3.12b4", :platform=>:ruby
gem "pg", "~> 0.11.0", :platform=>:ruby
gem "pg", "~> 0.16.0", :platform=>:ruby
gem "activerecord-jdbcmysql-adapter", "~> 1.1.3", :platform=>:jruby
gem "activerecord-jdbcpostgresql-adapter", "~> 1.1.3", :platform=>:jruby
gem "rails", "~> 3.1.0"
gem "riddle", :git=>"git://github.com/pat/riddle.git", :branch=>"develop"
gem "rails", "~> 4.1.0.beta1"

gemspec :path=>"../"
5 changes: 5 additions & 0 deletions lib/thinking_sphinx.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
if RUBY_PLATFORM == 'java'
require 'java'
require 'jdbc/mysql'
Jdbc::MySQL.load_driver
else
require 'mysql2'
end
Expand Down Expand Up @@ -46,6 +47,7 @@ module Subscribers; end
require 'thinking_sphinx/core'
require 'thinking_sphinx/configuration'
require 'thinking_sphinx/connection'
require 'thinking_sphinx/controller'
require 'thinking_sphinx/deletion'
require 'thinking_sphinx/errors'
require 'thinking_sphinx/excerpter'
Expand All @@ -58,16 +60,19 @@ module Subscribers; end
require 'thinking_sphinx/masks'
require 'thinking_sphinx/middlewares'
require 'thinking_sphinx/panes'
require 'thinking_sphinx/query'
require 'thinking_sphinx/rake_interface'
require 'thinking_sphinx/scopes'
require 'thinking_sphinx/search'
require 'thinking_sphinx/sphinxql'
require 'thinking_sphinx/subscribers/populator_subscriber'
require 'thinking_sphinx/test'
require 'thinking_sphinx/utf8'
require 'thinking_sphinx/wildcard'
# Extended
require 'thinking_sphinx/active_record'
require 'thinking_sphinx/deltas'
require 'thinking_sphinx/distributed'
require 'thinking_sphinx/real_time'

require 'thinking_sphinx/railtie' if defined?(Rails)
3 changes: 2 additions & 1 deletion lib/thinking_sphinx/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'active_record'
require 'joiner'

module ThinkingSphinx::ActiveRecord
module Callbacks; end
Expand All @@ -7,10 +8,10 @@ module Callbacks; end
require 'thinking_sphinx/active_record/property'
require 'thinking_sphinx/active_record/association'
require 'thinking_sphinx/active_record/association_proxy'
require 'thinking_sphinx/active_record/associations'
require 'thinking_sphinx/active_record/attribute'
require 'thinking_sphinx/active_record/base'
require 'thinking_sphinx/active_record/column'
require 'thinking_sphinx/active_record/column_sql_presenter'
require 'thinking_sphinx/active_record/database_adapters'
require 'thinking_sphinx/active_record/field'
require 'thinking_sphinx/active_record/filtered_reflection'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def indices
configuration.preload_indices
configuration.indices_for_references(
*@association.klass.name.underscore.to_sym
)
).reject &:distributed?
end
end

Expand Down
98 changes: 0 additions & 98 deletions lib/thinking_sphinx/active_record/associations.rb

This file was deleted.

13 changes: 6 additions & 7 deletions lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ class ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks <
callbacks :after_destroy

def after_destroy
indices.each { |index| ThinkingSphinx::Deletion.perform index, instance }
return if instance.new_record?

indices.each { |index|
ThinkingSphinx::Deletion.perform index, instance.id
}
end

private

def config
ThinkingSphinx::Configuration.instance
end

def indices
config.preload_indices
config.indices_for_references instance.class.name.underscore.to_sym
ThinkingSphinx::IndexSet.new([instance.class], []).to_a
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def config
end

def core_indices
@core_indices ||= indices.reject { |index| index.delta? }
@core_indices ||= indices.reject &:delta?
end

def delta_indices
@delta_indices ||= indices.select { |index| index.delta? }
@delta_indices ||= indices.select &:delta?
end

def delta_indices?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def after_update
return unless updates_enabled?

indices.each do |index|
update index
update index unless index.distributed?
end
end

Expand Down
Loading

0 comments on commit 4491f44

Please sign in to comment.