thinking-sphinx 1.5.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +15 -48
- data/VERSION +1 -0
- data/features/attribute_transformation.feature +7 -7
- data/features/attribute_updates.feature +16 -18
- data/features/deleting_instances.feature +13 -16
- data/features/excerpts.feature +0 -8
- data/features/facets.feature +19 -25
- data/features/handling_edits.feature +20 -25
- data/features/searching_across_models.feature +1 -1
- data/features/searching_by_index.feature +5 -6
- data/features/searching_by_model.feature +29 -29
- data/features/sphinx_scopes.feature +0 -26
- data/features/step_definitions/common_steps.rb +6 -18
- data/features/step_definitions/scope_steps.rb +0 -4
- data/features/step_definitions/search_steps.rb +4 -9
- data/features/support/env.rb +10 -3
- data/features/thinking_sphinx/db/fixtures/alphas.rb +10 -8
- data/features/thinking_sphinx/db/fixtures/cats.rb +1 -1
- data/features/thinking_sphinx/db/fixtures/dogs.rb +1 -1
- data/features/thinking_sphinx/db/fixtures/foxes.rb +1 -1
- data/features/thinking_sphinx/db/fixtures/people.rb +1 -1
- data/features/thinking_sphinx/db/fixtures/posts.rb +1 -5
- data/features/thinking_sphinx/db/migrations/create_posts.rb +0 -1
- data/features/thinking_sphinx/models/alpha.rb +0 -1
- data/features/thinking_sphinx/models/beta.rb +0 -5
- data/features/thinking_sphinx/models/developer.rb +1 -6
- data/features/thinking_sphinx/models/music.rb +1 -3
- data/features/thinking_sphinx/models/person.rb +1 -2
- data/features/thinking_sphinx/models/post.rb +0 -1
- data/lib/cucumber/thinking_sphinx/external_world.rb +4 -8
- data/lib/cucumber/thinking_sphinx/internal_world.rb +27 -36
- data/lib/thinking_sphinx.rb +60 -132
- data/lib/thinking_sphinx/active_record.rb +98 -124
- data/lib/thinking_sphinx/active_record/attribute_updates.rb +13 -17
- data/lib/thinking_sphinx/active_record/delta.rb +15 -21
- data/lib/thinking_sphinx/active_record/has_many_association.rb +23 -16
- data/lib/thinking_sphinx/active_record/scopes.rb +0 -18
- data/lib/thinking_sphinx/adapters/abstract_adapter.rb +15 -63
- data/lib/thinking_sphinx/adapters/mysql_adapter.rb +0 -4
- data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +24 -65
- data/lib/thinking_sphinx/association.rb +11 -36
- data/lib/thinking_sphinx/attribute.rb +85 -92
- data/lib/thinking_sphinx/auto_version.rb +3 -21
- data/lib/thinking_sphinx/class_facet.rb +3 -8
- data/lib/thinking_sphinx/configuration.rb +58 -114
- data/lib/thinking_sphinx/context.rb +20 -22
- data/lib/thinking_sphinx/core/array.rb +13 -0
- data/lib/thinking_sphinx/deltas.rb +0 -2
- data/lib/thinking_sphinx/deltas/default_delta.rb +22 -18
- data/lib/thinking_sphinx/deploy/capistrano.rb +31 -30
- data/lib/thinking_sphinx/excerpter.rb +1 -2
- data/lib/thinking_sphinx/facet.rb +35 -45
- data/lib/thinking_sphinx/facet_search.rb +24 -58
- data/lib/thinking_sphinx/field.rb +0 -18
- data/lib/thinking_sphinx/index.rb +36 -38
- data/lib/thinking_sphinx/index/builder.rb +59 -74
- data/lib/thinking_sphinx/property.rb +45 -66
- data/lib/thinking_sphinx/railtie.rb +35 -0
- data/lib/thinking_sphinx/search.rb +250 -506
- data/lib/thinking_sphinx/source.rb +31 -50
- data/lib/thinking_sphinx/source/internal_properties.rb +3 -8
- data/lib/thinking_sphinx/source/sql.rb +31 -71
- data/lib/thinking_sphinx/tasks.rb +27 -48
- data/spec/thinking_sphinx/active_record/delta_spec.rb +41 -36
- data/spec/thinking_sphinx/active_record/has_many_association_spec.rb +0 -96
- data/spec/thinking_sphinx/active_record/scopes_spec.rb +29 -29
- data/spec/thinking_sphinx/active_record_spec.rb +169 -140
- data/spec/thinking_sphinx/association_spec.rb +2 -20
- data/spec/thinking_sphinx/attribute_spec.rb +97 -101
- data/spec/thinking_sphinx/auto_version_spec.rb +11 -75
- data/spec/thinking_sphinx/configuration_spec.rb +62 -63
- data/spec/thinking_sphinx/context_spec.rb +66 -66
- data/spec/thinking_sphinx/facet_search_spec.rb +99 -99
- data/spec/thinking_sphinx/facet_spec.rb +4 -30
- data/spec/thinking_sphinx/field_spec.rb +3 -17
- data/spec/thinking_sphinx/index/builder_spec.rb +132 -169
- data/spec/thinking_sphinx/index_spec.rb +39 -45
- data/spec/thinking_sphinx/search_methods_spec.rb +33 -37
- data/spec/thinking_sphinx/search_spec.rb +269 -491
- data/spec/thinking_sphinx/source_spec.rb +48 -62
- data/spec/thinking_sphinx_spec.rb +49 -49
- data/tasks/distribution.rb +46 -0
- data/tasks/testing.rb +74 -0
- metadata +123 -199
- data/features/field_sorting.feature +0 -18
- data/features/thinking_sphinx/db/.gitignore +0 -1
- data/features/thinking_sphinx/db/fixtures/post_keywords.txt +0 -1
- data/features/thinking_sphinx/models/andrew.rb +0 -17
- data/lib/thinking-sphinx.rb +0 -1
- data/lib/thinking_sphinx/active_record/has_many_association_with_scopes.rb +0 -21
- data/lib/thinking_sphinx/bundled_search.rb +0 -40
- data/lib/thinking_sphinx/connection.rb +0 -71
- data/lib/thinking_sphinx/deltas/delete_job.rb +0 -16
- data/lib/thinking_sphinx/deltas/index_job.rb +0 -17
- data/lib/thinking_sphinx/rails_additions.rb +0 -181
- data/spec/fixtures/data.sql +0 -32
- data/spec/fixtures/database.yml.default +0 -3
- data/spec/fixtures/models.rb +0 -161
- data/spec/fixtures/structure.sql +0 -146
- data/spec/spec_helper.rb +0 -54
- data/spec/sphinx_helper.rb +0 -67
- data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +0 -163
- data/spec/thinking_sphinx/connection_spec.rb +0 -77
- data/spec/thinking_sphinx/rails_additions_spec.rb +0 -203
@@ -1,18 +0,0 @@
|
|
1
|
-
Feature: Field Sorting
|
2
|
-
In order to sort by strings
|
3
|
-
As a developer
|
4
|
-
I want to enable sorting by existing fields
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given Sphinx is running
|
8
|
-
And I am searching on people
|
9
|
-
|
10
|
-
Scenario: Searching with ordering on a sortable field
|
11
|
-
When I order by first_name
|
12
|
-
Then I should get 20 results
|
13
|
-
And the first_name of each result should indicate order
|
14
|
-
|
15
|
-
Scenario: Sort on a case insensitive sortable field
|
16
|
-
When I order by last_name
|
17
|
-
Then the first result's "last_name" should be "abbott"
|
18
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
database.yml
|
@@ -1 +0,0 @@
|
|
1
|
-
foo bar baz
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/person"
|
2
|
-
|
3
|
-
class Andrew < ActiveRecord::Base
|
4
|
-
set_table_name 'people'
|
5
|
-
|
6
|
-
define_index do
|
7
|
-
indexes first_name, last_name, street_address
|
8
|
-
end
|
9
|
-
|
10
|
-
sphinx_scope(:locked_first_name) {
|
11
|
-
{:conditions => {:first_name => 'Andrew'}}
|
12
|
-
}
|
13
|
-
sphinx_scope(:locked_last_name) {
|
14
|
-
{:conditions => {:last_name => 'Byrne'}}
|
15
|
-
}
|
16
|
-
default_sphinx_scope :locked_first_name
|
17
|
-
end
|
data/lib/thinking-sphinx.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'thinking_sphinx'
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ThinkingSphinx
|
2
|
-
module ActiveRecord
|
3
|
-
module HasManyAssociationWithScopes
|
4
|
-
def method_missing(method, *args, &block)
|
5
|
-
if responds_to_scope(method)
|
6
|
-
@reflection.klass.
|
7
|
-
search(:with => default_filter).
|
8
|
-
send(method, *args, &block)
|
9
|
-
else
|
10
|
-
super
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
def responds_to_scope(scope)
|
16
|
-
@reflection.klass.respond_to?(:sphinx_scopes) &&
|
17
|
-
@reflection.klass.sphinx_scopes.include?(scope)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module ThinkingSphinx
|
2
|
-
class BundledSearch
|
3
|
-
def initialize
|
4
|
-
@searches = []
|
5
|
-
end
|
6
|
-
|
7
|
-
def search(*args)
|
8
|
-
@searches << ThinkingSphinx.search(*args)
|
9
|
-
end
|
10
|
-
|
11
|
-
def search_for_ids(*args)
|
12
|
-
@searches << ThinkingSphinx.search_for_ids(*args)
|
13
|
-
end
|
14
|
-
|
15
|
-
def searches
|
16
|
-
populate
|
17
|
-
@searches
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def populated?
|
23
|
-
@populated
|
24
|
-
end
|
25
|
-
|
26
|
-
def populate
|
27
|
-
return if populated?
|
28
|
-
|
29
|
-
@populated = true
|
30
|
-
|
31
|
-
ThinkingSphinx::Connection.take do |client|
|
32
|
-
@searches.each { |search| search.append_to client }
|
33
|
-
|
34
|
-
client.run.each_with_index do |results, index|
|
35
|
-
searches[index].populate_from_queue results
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
class ThinkingSphinx::Connection
|
2
|
-
def self.pool
|
3
|
-
@pool ||= Innertube::Pool.new(
|
4
|
-
Proc.new { ThinkingSphinx::Connection.new },
|
5
|
-
Proc.new { |connection| connection.close }
|
6
|
-
)
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.take
|
10
|
-
retries = 0
|
11
|
-
original = nil
|
12
|
-
begin
|
13
|
-
pool.take do |connection|
|
14
|
-
connection.reset
|
15
|
-
begin
|
16
|
-
yield connection
|
17
|
-
rescue Riddle::ConnectionError, Riddle::ResponseError, SystemCallError => error
|
18
|
-
original = error
|
19
|
-
raise Innertube::Pool::BadResource
|
20
|
-
end
|
21
|
-
end
|
22
|
-
rescue Innertube::Pool::BadResource
|
23
|
-
retries += 1
|
24
|
-
retry if retries < 3
|
25
|
-
raise original
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def initialize
|
30
|
-
client.open
|
31
|
-
end
|
32
|
-
|
33
|
-
def client
|
34
|
-
@client ||= begin
|
35
|
-
client = Riddle::Client.new shuffled_addresses, configuration.port,
|
36
|
-
client_key
|
37
|
-
client.max_matches = _max_matches
|
38
|
-
client.timeout = configuration.timeout || 0
|
39
|
-
client
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def client_key
|
46
|
-
configuration.configuration.searchd.client_key
|
47
|
-
end
|
48
|
-
|
49
|
-
def configuration
|
50
|
-
ThinkingSphinx::Configuration.instance
|
51
|
-
end
|
52
|
-
|
53
|
-
def _max_matches
|
54
|
-
configuration.configuration.searchd.max_matches || 1000
|
55
|
-
end
|
56
|
-
|
57
|
-
def method_missing(method, *arguments, &block)
|
58
|
-
client.send method, *arguments, &block
|
59
|
-
end
|
60
|
-
|
61
|
-
def shuffled_addresses
|
62
|
-
return configuration.address unless configuration.shuffle
|
63
|
-
|
64
|
-
addresses = Array(configuration.address)
|
65
|
-
if addresses.respond_to?(:shuffle)
|
66
|
-
addresses.shuffle
|
67
|
-
else
|
68
|
-
address.sort_by { rand }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class ThinkingSphinx::Deltas::DeleteJob
|
2
|
-
def initialize(indices, document_id)
|
3
|
-
@indices, @document_id = indices, document_id
|
4
|
-
end
|
5
|
-
|
6
|
-
def perform
|
7
|
-
ThinkingSphinx::Connection.take do |client|
|
8
|
-
@indices.each do |index|
|
9
|
-
client.update(index, ['sphinx_deleted'], {@document_id => [1]})
|
10
|
-
end
|
11
|
-
end
|
12
|
-
rescue Riddle::ConnectionError, Riddle::ResponseError,
|
13
|
-
ThinkingSphinx::SphinxError, Errno::ETIMEDOUT, Timeout::Error
|
14
|
-
# Not the end of the world if Sphinx isn't running.
|
15
|
-
end
|
16
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class ThinkingSphinx::Deltas::IndexJob
|
2
|
-
def initialize(indices)
|
3
|
-
@indices = indices
|
4
|
-
@indices << {:verbose => !ThinkingSphinx.suppress_delta_output?}
|
5
|
-
end
|
6
|
-
|
7
|
-
def perform
|
8
|
-
ThinkingSphinx::Configuration.instance.controller.index *@indices
|
9
|
-
ThinkingSphinx::Connection.pool.clear
|
10
|
-
|
11
|
-
true
|
12
|
-
end
|
13
|
-
|
14
|
-
def configuration
|
15
|
-
ThinkingSphinx::Configuration.instance
|
16
|
-
end
|
17
|
-
end
|
@@ -1,181 +0,0 @@
|
|
1
|
-
module ThinkingSphinx
|
2
|
-
module HashExcept
|
3
|
-
# Returns a new hash without the given keys.
|
4
|
-
def except(*keys)
|
5
|
-
rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
|
6
|
-
reject { |key,| rejected.include?(key) }
|
7
|
-
end
|
8
|
-
|
9
|
-
# Replaces the hash without only the given keys.
|
10
|
-
def except!(*keys)
|
11
|
-
replace(except(*keys))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
Hash.send(
|
17
|
-
:include, ThinkingSphinx::HashExcept
|
18
|
-
) unless Hash.instance_methods.include?("except")
|
19
|
-
|
20
|
-
module ThinkingSphinx
|
21
|
-
module ArrayExtractOptions
|
22
|
-
def extract_options!
|
23
|
-
last.is_a?(::Hash) ? pop : {}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
Array.send(
|
29
|
-
:include, ThinkingSphinx::ArrayExtractOptions
|
30
|
-
) unless Array.instance_methods.include?("extract_options!")
|
31
|
-
|
32
|
-
module ThinkingSphinx
|
33
|
-
module AbstractQuotedTableName
|
34
|
-
def quote_table_name(name)
|
35
|
-
quote_column_name(name)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(
|
41
|
-
:include, ThinkingSphinx::AbstractQuotedTableName
|
42
|
-
) unless ActiveRecord::ConnectionAdapters::AbstractAdapter.instance_methods.include?("quote_table_name")
|
43
|
-
|
44
|
-
module ThinkingSphinx
|
45
|
-
module MysqlQuotedTableName
|
46
|
-
def quote_table_name(name) #:nodoc:
|
47
|
-
quote_column_name(name).gsub('.', '`.`')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
if ActiveRecord::ConnectionAdapters.constants.include?("MysqlAdapter") or ActiveRecord::Base.respond_to?(:jdbcmysql_connection)
|
53
|
-
adapter = ActiveRecord::ConnectionAdapters.const_get(
|
54
|
-
defined?(JRUBY_VERSION) ? :JdbcAdapter : :MysqlAdapter
|
55
|
-
)
|
56
|
-
unless adapter.instance_methods.include?("quote_table_name")
|
57
|
-
adapter.send(:include, ThinkingSphinx::MysqlQuotedTableName)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
module ThinkingSphinx
|
62
|
-
module ActiveRecordQuotedName
|
63
|
-
def quoted_table_name
|
64
|
-
self.connection.quote_table_name(self.table_name)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
ActiveRecord::Base.extend(
|
70
|
-
ThinkingSphinx::ActiveRecordQuotedName
|
71
|
-
) unless ActiveRecord::Base.respond_to?("quoted_table_name")
|
72
|
-
|
73
|
-
module ThinkingSphinx
|
74
|
-
module ActiveRecordStoreFullSTIClass
|
75
|
-
def store_full_sti_class
|
76
|
-
false
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
ActiveRecord::Base.extend(
|
82
|
-
ThinkingSphinx::ActiveRecordStoreFullSTIClass
|
83
|
-
) unless ActiveRecord::Base.respond_to?(:store_full_sti_class)
|
84
|
-
|
85
|
-
module ThinkingSphinx
|
86
|
-
module ClassAttributeMethods
|
87
|
-
def cattr_reader(*syms)
|
88
|
-
syms.flatten.each do |sym|
|
89
|
-
next if sym.is_a?(Hash)
|
90
|
-
class_eval(<<-EOS, __FILE__, __LINE__)
|
91
|
-
unless defined? @@#{sym}
|
92
|
-
@@#{sym} = nil
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.#{sym}
|
96
|
-
@@#{sym}
|
97
|
-
end
|
98
|
-
|
99
|
-
def #{sym}
|
100
|
-
@@#{sym}
|
101
|
-
end
|
102
|
-
EOS
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def cattr_writer(*syms)
|
107
|
-
options = syms.extract_options!
|
108
|
-
syms.flatten.each do |sym|
|
109
|
-
class_eval(<<-EOS, __FILE__, __LINE__)
|
110
|
-
unless defined? @@#{sym}
|
111
|
-
@@#{sym} = nil
|
112
|
-
end
|
113
|
-
|
114
|
-
def self.#{sym}=(obj)
|
115
|
-
@@#{sym} = obj
|
116
|
-
end
|
117
|
-
|
118
|
-
#{"
|
119
|
-
def #{sym}=(obj)
|
120
|
-
@@#{sym} = obj
|
121
|
-
end
|
122
|
-
" unless options[:instance_writer] == false }
|
123
|
-
EOS
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def cattr_accessor(*syms)
|
128
|
-
cattr_reader(*syms)
|
129
|
-
cattr_writer(*syms)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
Class.extend(
|
135
|
-
ThinkingSphinx::ClassAttributeMethods
|
136
|
-
) unless Class.respond_to?(:cattr_reader)
|
137
|
-
|
138
|
-
module ThinkingSphinx
|
139
|
-
module SingletonClass
|
140
|
-
def singleton_class
|
141
|
-
class << self
|
142
|
-
self
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
unless Object.new.respond_to?(:singleton_class)
|
149
|
-
Object.send(:include, ThinkingSphinx::SingletonClass)
|
150
|
-
end
|
151
|
-
|
152
|
-
module ThinkingSphinx
|
153
|
-
module ObjectTry
|
154
|
-
def try(*a, &b)
|
155
|
-
if a.empty? && block_given?
|
156
|
-
yield self
|
157
|
-
else
|
158
|
-
__send__(*a, &b)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
module NilClassTry
|
164
|
-
def try(*args)
|
165
|
-
nil
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
Object.send(:include, ThinkingSphinx::ObjectTry) unless Object.new.respond_to?(:try)
|
171
|
-
NilClass.send(:include, ThinkingSphinx::NilClassTry) unless nil.respond_to?(:try)
|
172
|
-
|
173
|
-
module ThinkingSphinx
|
174
|
-
module EnumerableOne
|
175
|
-
def one?(&block)
|
176
|
-
select(&block).size == 1
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
Enumerable.send(:include, ThinkingSphinx::EnumerableOne) unless [].respond_to?(:one?)
|
data/spec/fixtures/data.sql
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Ellie','K','Ford','38 Mills Street','Eagle Farm Bc','QLD','4009','Ellie.K.Ford@mailinator.com','1970/1/23 00:00:00', 3, 'CricketTeam');
|
2
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Aaliyah','E','Allen','71 Murphy Street','Wyola West','WA','6407','Aaliyah.E.Allen@dodgit.com','1980/3/23 00:00:00', 3, 'CricketTeam');
|
3
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('male','Callum','C','Miah','89 Dalgarno Street','Bullawa Creek','NSW','2390','Callum.C.Miah@trashymail.com','1973/3/25 00:00:00', 3, 'CricketTeam');
|
4
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('male','Finley','L','Buckley','18 Queen Street','Manly Vale','NSW','2093','Finley.L.Buckley@spambob.com','1962/11/20 00:00:00', 3, 'CricketTeam');
|
5
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Poppy','A','Hilton','36 Nerrigundah Drive','Nyora','VIC','3987','Poppy.A.Hilton@dodgit.com','1972/10/30 00:00:00', 3, 'CricketTeam');
|
6
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Eloise','Z','Kennedy','18 Mt Berryman Road','Lilydale','QLD','4344','Eloise.Z.Kennedy@spambob.com','1973/9/28 00:00:00', 3, 'CricketTeam');
|
7
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Shannon','L','Manning','60 Ocean Pde','Greenvale','QLD','4816','Shannon.L.Manning@dodgit.com','1956/6/13 00:00:00', 3, 'FootballTeam');
|
8
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('male','Oscar','C','Lawson','43 Feather Street','Battery Hill','QLD','4551','Oscar.C.Lawson@spambob.com','1979/10/17 00:00:00', 3, 'CricketTeam');
|
9
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Sofia','K','Bray','26 Clifton Street','Pental Island','VIC','3586','Sofia.K.Bray@mailinator.com','1970/5/10 00:00:00', 3, 'CricketTeam');
|
10
|
-
insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('male','Andrew','N','Byrne','35 Cecil Street','Monash Park','NSW','2111','Andrew.N.Byrne@spambob.com','1983/2/16 00:00:00', 3, 'CricketTeam');
|
11
|
-
|
12
|
-
insert into `alphas` (name) values ('one');
|
13
|
-
insert into `alphas` (name) values ('two');
|
14
|
-
insert into `alphas` (name) values ('three');
|
15
|
-
insert into `alphas` (name) values ('four');
|
16
|
-
insert into `alphas` (name) values ('five');
|
17
|
-
insert into `alphas` (name) values ('six');
|
18
|
-
insert into `alphas` (name) values ('seven');
|
19
|
-
insert into `alphas` (name) values ('eight');
|
20
|
-
insert into `alphas` (name) values ('nine');
|
21
|
-
insert into `alphas` (name) values ('ten');
|
22
|
-
|
23
|
-
insert into `betas` (name) values ('one');
|
24
|
-
insert into `betas` (name) values ('two');
|
25
|
-
insert into `betas` (name) values ('three');
|
26
|
-
insert into `betas` (name) values ('four');
|
27
|
-
insert into `betas` (name) values ('five');
|
28
|
-
insert into `betas` (name) values ('six');
|
29
|
-
insert into `betas` (name) values ('seven');
|
30
|
-
insert into `betas` (name) values ('eight');
|
31
|
-
insert into `betas` (name) values ('nine');
|
32
|
-
insert into `betas` (name) values ('ten');
|
data/spec/fixtures/models.rb
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
class Tag < ActiveRecord::Base
|
2
|
-
belongs_to :person
|
3
|
-
belongs_to :football_team
|
4
|
-
belongs_to :cricket_team
|
5
|
-
end
|
6
|
-
|
7
|
-
class FootballTeam < ActiveRecord::Base
|
8
|
-
has_many :tags
|
9
|
-
has_many :people, :through => :tags
|
10
|
-
end
|
11
|
-
|
12
|
-
class CricketTeam < ActiveRecord::Base
|
13
|
-
has_many :people, :foreign_key => :team_id
|
14
|
-
|
15
|
-
define_index do
|
16
|
-
indexes :name
|
17
|
-
has "SELECT cricket_team_id, id FROM tags", :source => :query, :as => :tags
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Contact < ActiveRecord::Base
|
22
|
-
belongs_to :person
|
23
|
-
end
|
24
|
-
|
25
|
-
class Friendship < ActiveRecord::Base
|
26
|
-
belongs_to :person
|
27
|
-
belongs_to :friend, :class_name => "Person", :foreign_key => :friend_id
|
28
|
-
|
29
|
-
define_index do
|
30
|
-
indexes "'something'", :as => :something
|
31
|
-
has person_id, friend_id
|
32
|
-
|
33
|
-
set_property :latitude_attr => :person_id
|
34
|
-
set_property :longitude_attr => :person_id
|
35
|
-
end
|
36
|
-
|
37
|
-
sphinx_scope(:reverse) {
|
38
|
-
{:order => "@weight ASC"}
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
class Link < ActiveRecord::Base
|
43
|
-
has_and_belongs_to_many :people
|
44
|
-
end
|
45
|
-
|
46
|
-
class Person < ActiveRecord::Base
|
47
|
-
belongs_to :team, :polymorphic => :true
|
48
|
-
belongs_to :source, :polymorphic => :true
|
49
|
-
has_many :contacts
|
50
|
-
|
51
|
-
has_many :friendships
|
52
|
-
has_many :friends, :through => :friendships
|
53
|
-
|
54
|
-
has_many :tags
|
55
|
-
has_many :football_teams, :through => :tags
|
56
|
-
|
57
|
-
has_and_belongs_to_many :links
|
58
|
-
|
59
|
-
define_index do
|
60
|
-
indexes [first_name, middle_initial, last_name], :as => :name
|
61
|
-
indexes team.name, :as => :team_name
|
62
|
-
indexes contacts.phone_number, :as => :phone_numbers
|
63
|
-
indexes city, :prefixes => true, :facet => true
|
64
|
-
indexes state, :infixes => true, :facet => true
|
65
|
-
|
66
|
-
has [first_name, middle_initial, last_name], :as => :name_sort
|
67
|
-
has team.name, :as => :team_name_sort
|
68
|
-
|
69
|
-
has [:id, :team_id], :as => :ids
|
70
|
-
has team(:id), :as => :team_id
|
71
|
-
has football_teams(:id), :as => :football_team_id
|
72
|
-
|
73
|
-
has contacts.phone_number, :as => :phone_number_sort
|
74
|
-
has contacts(:id), :as => :contact_ids
|
75
|
-
|
76
|
-
has birthday, :facet => true
|
77
|
-
|
78
|
-
has friendships.person_id, :as => :friendly_ids
|
79
|
-
|
80
|
-
has :id, :as => :latitude
|
81
|
-
has :id, :as => :longitude
|
82
|
-
|
83
|
-
set_property :delta => true
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class Parent < Person
|
88
|
-
end
|
89
|
-
|
90
|
-
module Admin
|
91
|
-
class Person < ::Person
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
class Child < Person
|
96
|
-
belongs_to :parent
|
97
|
-
define_index do
|
98
|
-
indexes [parent.first_name, parent.middle_initial, parent.last_name], :as => :parent_name
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
class Alpha < ActiveRecord::Base
|
103
|
-
has_many :betas
|
104
|
-
has_many :thetas
|
105
|
-
|
106
|
-
define_index do
|
107
|
-
indexes :name, :sortable => true
|
108
|
-
|
109
|
-
has :id, :as => :lat
|
110
|
-
has :id, :as => :lng
|
111
|
-
|
112
|
-
set_property :field_weights => {"name" => 10}
|
113
|
-
end
|
114
|
-
|
115
|
-
def big_name
|
116
|
-
name.upcase
|
117
|
-
end
|
118
|
-
|
119
|
-
def sphinx_attributes
|
120
|
-
:existing
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
class Beta < ActiveRecord::Base
|
125
|
-
has_many :gammas
|
126
|
-
|
127
|
-
define_index do
|
128
|
-
indexes :name, :sortable => true
|
129
|
-
|
130
|
-
has :id, :as => :lat
|
131
|
-
has :id, :as => :lon
|
132
|
-
|
133
|
-
set_property :delta => true
|
134
|
-
end
|
135
|
-
|
136
|
-
def excerpts
|
137
|
-
false
|
138
|
-
end
|
139
|
-
|
140
|
-
def matching_fields
|
141
|
-
:foo
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
class Gamma < ActiveRecord::Base
|
146
|
-
#
|
147
|
-
end
|
148
|
-
|
149
|
-
class Theta < ActiveRecord::Base
|
150
|
-
#
|
151
|
-
end
|
152
|
-
|
153
|
-
class Search < ActiveRecord::Base
|
154
|
-
#
|
155
|
-
end
|
156
|
-
|
157
|
-
class BigFoo < ActiveRecord::Base
|
158
|
-
define_index do
|
159
|
-
indexes name
|
160
|
-
end
|
161
|
-
end
|