warp-thinking-sphinx 1.2.12 → 1.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +21 -4
- data/VERSION +1 -0
- data/features/abstract_inheritance.feature +10 -0
- data/features/alternate_primary_key.feature +1 -1
- data/features/attribute_updates.feature +22 -5
- data/features/deleting_instances.feature +3 -0
- data/features/facets.feature +6 -0
- data/features/facets_across_model.feature +2 -2
- data/features/searching_across_models.feature +1 -1
- data/features/searching_by_index.feature +40 -0
- data/features/sphinx_scopes.feature +7 -0
- data/features/step_definitions/alpha_steps.rb +14 -1
- data/features/step_definitions/beta_steps.rb +1 -1
- data/features/step_definitions/common_steps.rb +12 -2
- data/features/step_definitions/facet_steps.rb +5 -1
- data/features/step_definitions/scope_steps.rb +4 -0
- data/features/step_definitions/sphinx_steps.rb +8 -4
- data/features/sti_searching.feature +5 -0
- data/features/support/{db/database.example.yml → database.example.yml} +0 -0
- data/features/support/db/fixtures/foxes.rb +3 -0
- data/features/support/db/fixtures/music.rb +4 -0
- data/features/support/db/fixtures/robots.rb +1 -1
- data/features/support/db/fixtures/tags.rb +1 -1
- data/features/support/db/migrations/create_alphas.rb +1 -0
- data/features/support/db/migrations/create_genres.rb +3 -0
- data/features/support/db/migrations/create_music.rb +6 -0
- data/features/support/db/migrations/create_robots.rb +1 -2
- data/features/support/env.rb +16 -1
- data/features/support/models/alpha.rb +12 -0
- data/features/support/models/comment.rb +3 -3
- data/features/support/models/fox.rb +5 -0
- data/features/support/models/genre.rb +3 -0
- data/features/support/models/medium.rb +5 -0
- data/features/support/models/music.rb +8 -0
- data/features/support/models/post.rb +2 -1
- data/features/support/models/robot.rb +4 -0
- data/lib/cucumber/thinking_sphinx/external_world.rb +8 -0
- data/lib/cucumber/thinking_sphinx/internal_world.rb +126 -0
- data/lib/cucumber/thinking_sphinx/sql_logger.rb +20 -0
- data/lib/thinking_sphinx.rb +56 -37
- data/lib/thinking_sphinx/active_record.rb +257 -192
- data/lib/thinking_sphinx/active_record/attribute_updates.rb +10 -12
- data/lib/thinking_sphinx/active_record/delta.rb +0 -26
- data/lib/thinking_sphinx/active_record/scopes.rb +37 -1
- data/lib/thinking_sphinx/adapters/mysql_adapter.rb +1 -1
- data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +18 -11
- data/lib/thinking_sphinx/attribute.rb +19 -4
- data/lib/thinking_sphinx/auto_version.rb +22 -0
- data/lib/thinking_sphinx/configuration.rb +57 -59
- data/lib/thinking_sphinx/context.rb +74 -0
- data/lib/thinking_sphinx/deltas.rb +0 -2
- data/lib/thinking_sphinx/deltas/default_delta.rb +14 -20
- data/lib/thinking_sphinx/deploy/capistrano.rb +1 -1
- data/lib/thinking_sphinx/facet_search.rb +3 -1
- data/lib/thinking_sphinx/index.rb +77 -19
- data/lib/thinking_sphinx/index/builder.rb +2 -2
- data/lib/thinking_sphinx/search.rb +47 -9
- data/lib/thinking_sphinx/search_methods.rb +22 -4
- data/lib/thinking_sphinx/source.rb +9 -8
- data/lib/thinking_sphinx/source/sql.rb +5 -3
- data/lib/thinking_sphinx/tasks.rb +13 -57
- data/lib/thinking_sphinx/test.rb +52 -0
- data/rails/init.rb +4 -2
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/active_record/delta_spec.rb +4 -6
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/active_record/has_many_association_spec.rb +0 -0
- data/spec/thinking_sphinx/active_record/scopes_spec.rb +177 -0
- data/spec/thinking_sphinx/active_record_spec.rb +622 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/association_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/attribute_spec.rb +39 -0
- data/spec/thinking_sphinx/auto_version_spec.rb +39 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/configuration_spec.rb +27 -61
- data/spec/thinking_sphinx/context_spec.rb +119 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/core/array_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/core/string_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/excerpter_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/facet_search_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/facet_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/field_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/index/builder_spec.rb +24 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/index/faux_column_spec.rb +0 -0
- data/spec/thinking_sphinx/index_spec.rb +183 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/rails_additions_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/search_methods_spec.rb +0 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/search_spec.rb +41 -0
- data/spec/{lib/thinking_sphinx → thinking_sphinx}/source_spec.rb +1 -1
- data/spec/thinking_sphinx_spec.rb +204 -0
- data/tasks/distribution.rb +6 -20
- data/tasks/testing.rb +8 -19
- metadata +117 -142
- data/VERSION.yml +0 -4
- data/features/a.rb +0 -17
- data/features/datetime_deltas.feature +0 -66
- data/features/delayed_delta_indexing.feature +0 -37
- data/features/step_definitions/datetime_delta_steps.rb +0 -15
- data/features/step_definitions/delayed_delta_indexing_steps.rb +0 -7
- data/features/support/db/active_record.rb +0 -40
- data/features/support/db/fixtures/delayed_betas.rb +0 -10
- data/features/support/db/fixtures/thetas.rb +0 -10
- data/features/support/db/migrations/create_delayed_betas.rb +0 -17
- data/features/support/db/migrations/create_thetas.rb +0 -5
- data/features/support/db/mysql.rb +0 -3
- data/features/support/db/postgresql.rb +0 -3
- data/features/support/models/delayed_beta.rb +0 -7
- data/features/support/models/theta.rb +0 -7
- data/features/support/post_database.rb +0 -43
- data/features/support/z.rb +0 -19
- data/lib/thinking_sphinx/deltas/datetime_delta.rb +0 -50
- data/lib/thinking_sphinx/deltas/delayed_delta.rb +0 -30
- data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +0 -24
- data/lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb +0 -27
- data/lib/thinking_sphinx/deltas/delayed_delta/job.rb +0 -26
- data/spec/lib/thinking_sphinx/active_record/scopes_spec.rb +0 -96
- data/spec/lib/thinking_sphinx/active_record_spec.rb +0 -353
- data/spec/lib/thinking_sphinx/deltas/job_spec.rb +0 -32
- data/spec/lib/thinking_sphinx/index_spec.rb +0 -45
- data/spec/lib/thinking_sphinx_spec.rb +0 -162
- data/vendor/after_commit/LICENSE +0 -20
- data/vendor/after_commit/README +0 -16
- data/vendor/after_commit/Rakefile +0 -22
- data/vendor/after_commit/init.rb +0 -8
- data/vendor/after_commit/lib/after_commit.rb +0 -45
- data/vendor/after_commit/lib/after_commit/active_record.rb +0 -114
- data/vendor/after_commit/lib/after_commit/connection_adapters.rb +0 -103
- data/vendor/after_commit/test/after_commit_test.rb +0 -53
- data/vendor/delayed_job/lib/delayed/job.rb +0 -251
- data/vendor/delayed_job/lib/delayed/message_sending.rb +0 -7
- data/vendor/delayed_job/lib/delayed/performable_method.rb +0 -55
- data/vendor/delayed_job/lib/delayed/worker.rb +0 -54
- data/vendor/riddle/lib/riddle.rb +0 -30
- data/vendor/riddle/lib/riddle/client.rb +0 -635
- data/vendor/riddle/lib/riddle/client/filter.rb +0 -53
- data/vendor/riddle/lib/riddle/client/message.rb +0 -66
- data/vendor/riddle/lib/riddle/client/response.rb +0 -84
- data/vendor/riddle/lib/riddle/configuration.rb +0 -33
- data/vendor/riddle/lib/riddle/configuration/distributed_index.rb +0 -48
- data/vendor/riddle/lib/riddle/configuration/index.rb +0 -142
- data/vendor/riddle/lib/riddle/configuration/indexer.rb +0 -19
- data/vendor/riddle/lib/riddle/configuration/remote_index.rb +0 -17
- data/vendor/riddle/lib/riddle/configuration/searchd.rb +0 -25
- data/vendor/riddle/lib/riddle/configuration/section.rb +0 -43
- data/vendor/riddle/lib/riddle/configuration/source.rb +0 -23
- data/vendor/riddle/lib/riddle/configuration/sql_source.rb +0 -34
- data/vendor/riddle/lib/riddle/configuration/xml_source.rb +0 -28
- data/vendor/riddle/lib/riddle/controller.rb +0 -53
data/README.textile
CHANGED
@@ -14,16 +14,20 @@ To quickly see if your system is ready to run the thinking sphinx specs, run the
|
|
14
14
|
|
15
15
|
To get the spec suite running, you will need to install the ginger gem:
|
16
16
|
|
17
|
-
|
17
|
+
<pre><code>sudo gem install ginger --source http://gemcutter.org</code></pre>
|
18
18
|
|
19
|
-
Then install the cucumber, yard, jeweler and rspec gems. Make sure you have a git install version 1.6.0.0 or higher, otherwise the jeweler gem won't install.
|
19
|
+
Then install the cucumber, yard, jeweler and rspec gems. Make sure you have a git install version 1.6.0.0 or higher, otherwise the jeweler gem won't install. Bluecloth is required for some of the yard documentation.
|
20
20
|
|
21
|
-
|
21
|
+
<pre>
|
22
|
+
sudo gem install bluecloth cucumber yard jeweler rspec
|
23
|
+
</pre>
|
22
24
|
|
23
25
|
Then set up your database:
|
24
26
|
|
25
|
-
|
27
|
+
<pre>
|
28
|
+
cp spec/fixtures/database.yml.default spec/fixtures/database.yml &&
|
26
29
|
mysqladmin -u root create thinking_sphinx
|
30
|
+
</pre>
|
27
31
|
|
28
32
|
This last step can be done automatically by the contribute.rb script if all dependencies are met.
|
29
33
|
|
@@ -32,11 +36,15 @@ in the app root.
|
|
32
36
|
|
33
37
|
You should now have a passing test suite from which to build your patch on.
|
34
38
|
|
39
|
+
<pre>
|
35
40
|
rake spec
|
41
|
+
</pre>
|
36
42
|
|
37
43
|
If you get the message "Failed to start searchd daemon", run the spec with sudo:
|
38
44
|
|
45
|
+
<pre>
|
39
46
|
sudo rake spec
|
47
|
+
</pre>
|
40
48
|
|
41
49
|
If you quit the spec suite before it's completed, you may be left with data in the test
|
42
50
|
database, causing the next run to have failures. Let that run complete and then try again.
|
@@ -142,3 +150,12 @@ Since I first released this library, there's been quite a few people who have su
|
|
142
150
|
* Christian Aust
|
143
151
|
* Martin Sarasale
|
144
152
|
* Édouard Brière
|
153
|
+
* Steve Madsen
|
154
|
+
* Justin DeWind
|
155
|
+
* Chris Z
|
156
|
+
* Chris Roos
|
157
|
+
* Andrew Assarattanakul
|
158
|
+
* Jonas von Andrian
|
159
|
+
* Dimitri Krassovski
|
160
|
+
* Sergey Kojin
|
161
|
+
* Brad Sumersford
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.3.10
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Abstract inheritance
|
2
|
+
In order to use Thinking Sphinx in complex situations
|
3
|
+
As a developer
|
4
|
+
I want to define indexes on subclasses of abstract models
|
5
|
+
|
6
|
+
Scenario: Searching on subclasses of abstract models
|
7
|
+
Given Sphinx is running
|
8
|
+
And I am searching on music
|
9
|
+
When I search
|
10
|
+
Then I should get 3 results
|
@@ -9,15 +9,21 @@ Feature: Update attributes directly to Sphinx
|
|
9
9
|
When I filter by 3 on value
|
10
10
|
Then I should get 1 result
|
11
11
|
|
12
|
-
When I change the value of alpha
|
13
|
-
And I wait for Sphinx to catch up
|
12
|
+
When I change the value of alpha four to 13
|
13
|
+
And I wait for Sphinx to catch up
|
14
14
|
And I filter by 13 on value
|
15
|
+
And I use index alpha_core
|
16
|
+
Then I should get 1 result
|
17
|
+
When I use index alternative_core
|
15
18
|
Then I should get 1 result
|
16
19
|
|
17
|
-
When I change the value of alpha
|
18
|
-
And I wait for Sphinx to catch up
|
20
|
+
When I change the value of alpha four to 4
|
21
|
+
And I wait for Sphinx to catch up
|
19
22
|
And I filter by 13 on value
|
23
|
+
And I use index alpha_core
|
20
24
|
Then I should get 0 results
|
25
|
+
When I use index alternative_core
|
26
|
+
Then I should get 0 result
|
21
27
|
|
22
28
|
Scenario: Updating attributes in Sphinx with delta indexes
|
23
29
|
Given Sphinx is running
|
@@ -30,4 +36,15 @@ Feature: Update attributes directly to Sphinx
|
|
30
36
|
Then I should get 1 result
|
31
37
|
|
32
38
|
When I search for the document id of beta eight in the beta_delta index
|
33
|
-
Then it should not exist
|
39
|
+
Then it should not exist
|
40
|
+
|
41
|
+
Scenario: Updating boolean attribute in Sphinx
|
42
|
+
Given Sphinx is running
|
43
|
+
And I am searching on alphas
|
44
|
+
When I filter by active alphas
|
45
|
+
Then I should get 10 results
|
46
|
+
|
47
|
+
When I flag alpha five as inactive
|
48
|
+
And I wait for Sphinx to catch up
|
49
|
+
And I filter by active alphas
|
50
|
+
Then I should get 9 results
|
@@ -56,6 +56,9 @@ Feature: Keeping Sphinx in line with deleted model instances
|
|
56
56
|
And I am searching on betas
|
57
57
|
When I create a new beta named thirteen
|
58
58
|
And I wait for Sphinx to catch up
|
59
|
+
And I search for thirteen
|
60
|
+
Then I should get 1 result
|
61
|
+
|
59
62
|
And I disable delta updates
|
60
63
|
And I destroy beta thirteen
|
61
64
|
And I wait for Sphinx to catch up
|
data/features/facets.feature
CHANGED
@@ -74,3 +74,9 @@ Feature: Search and browse models by their defined facets
|
|
74
74
|
Then the Tags facet should have an "Australia" key
|
75
75
|
Then the Tags facet should have an "Melbourne" key
|
76
76
|
Then the Tags facet should have an "Victoria" key
|
77
|
+
|
78
|
+
Scenario: Requesting MVA facets from source queries
|
79
|
+
Given Sphinx is running
|
80
|
+
And I am searching on posts
|
81
|
+
When I am requesting facet results
|
82
|
+
Then the Comment Ids facet should have 9 keys
|
@@ -5,7 +5,7 @@ Feature: Search and browse across models by their defined facets
|
|
5
5
|
When I am requesting facet results
|
6
6
|
And I want all possible attributes
|
7
7
|
Then I should have valid facet results
|
8
|
-
And I should have
|
8
|
+
And I should have 11 facets
|
9
9
|
And I should have the facet Class
|
10
10
|
And the Class facet should have a "Person" key
|
11
11
|
And I should have the facet Gender
|
@@ -19,7 +19,7 @@ Feature: Search and browse across models by their defined facets
|
|
19
19
|
When I am requesting facet results
|
20
20
|
And I want all possible attributes
|
21
21
|
And I don't want classes included
|
22
|
-
Then I should have
|
22
|
+
Then I should have 10 facets
|
23
23
|
And I should not have the facet Class
|
24
24
|
|
25
25
|
Scenario: Requesting facets common to all indexed models
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: Searching within a single index
|
2
|
+
In order to use Thinking Sphinx's core functionality
|
3
|
+
A developer
|
4
|
+
Should be able to search on a single index
|
5
|
+
|
6
|
+
Scenario: Searching with alternative index
|
7
|
+
Given Sphinx is running
|
8
|
+
And I am searching on alphas
|
9
|
+
When I order by value
|
10
|
+
And I use index alternative_core
|
11
|
+
Then I should get 7 results
|
12
|
+
|
13
|
+
Scenario: Searching with default index
|
14
|
+
Given Sphinx is running
|
15
|
+
And I am searching on alphas
|
16
|
+
When I order by value
|
17
|
+
And I use index alpha_core
|
18
|
+
Then I should get 10 results
|
19
|
+
|
20
|
+
Scenario: Searching without specified index
|
21
|
+
Given Sphinx is running
|
22
|
+
And I am searching on alphas
|
23
|
+
When I order by value
|
24
|
+
Then I should get 10 results
|
25
|
+
|
26
|
+
Scenario: Deleting instances from the core index
|
27
|
+
Given Sphinx is running
|
28
|
+
And I am searching on alphas
|
29
|
+
|
30
|
+
When I create a new alpha named eleven
|
31
|
+
And I process the alpha_core index
|
32
|
+
And I process the alternative_core index
|
33
|
+
And I wait for Sphinx to catch up
|
34
|
+
And I search for eleven
|
35
|
+
Then I should get 1 result
|
36
|
+
|
37
|
+
When I destroy alpha eleven
|
38
|
+
And I wait for Sphinx to catch up
|
39
|
+
And I search for eleven
|
40
|
+
Then I should get 0 results
|
@@ -33,3 +33,10 @@ Feature: Sphinx Scopes
|
|
33
33
|
And I am searching on people
|
34
34
|
When I use the ids_only scope
|
35
35
|
Then I should have an array of integers
|
36
|
+
|
37
|
+
Scenario: Counts with scopes
|
38
|
+
Given Sphinx is running
|
39
|
+
And I am searching on people
|
40
|
+
When I use the with_first_name scope set to "Andrew"
|
41
|
+
And I am retrieving the scoped result count
|
42
|
+
Then I should get a value of 7
|
@@ -1,3 +1,16 @@
|
|
1
|
+
When /^I create a new alpha named (\w+)$/ do |name|
|
2
|
+
Alpha.create!(:name => name, :value => 101)
|
3
|
+
end
|
4
|
+
|
1
5
|
When /^I change the (\w+) of alpha (\w+) to (\w+)$/ do |column, name, replacement|
|
2
6
|
Alpha.find_by_name(name).update_attributes(column.to_sym => replacement)
|
3
|
-
end
|
7
|
+
end
|
8
|
+
|
9
|
+
When /^I filter by active alphas$/ do
|
10
|
+
@results = nil
|
11
|
+
@with[:active] = true
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^I flag alpha (\w+) as inactive$/ do |name|
|
15
|
+
Alpha.find_by_name(name).update_attributes(:active => false)
|
16
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
Before do
|
2
2
|
$queries_executed = []
|
3
|
-
ThinkingSphinx::Deltas::Job.cancel_thinking_sphinx_jobs
|
4
3
|
|
5
4
|
@model = nil
|
6
5
|
@method = :search
|
@@ -11,6 +10,8 @@ Before do
|
|
11
10
|
@with_all = {}
|
12
11
|
@options = {}
|
13
12
|
@results = nil
|
13
|
+
|
14
|
+
Given "updates are enabled"
|
14
15
|
end
|
15
16
|
|
16
17
|
Given /^I am searching on (.+)$/ do |model|
|
@@ -26,6 +27,11 @@ When /^I am searching for ids$/ do
|
|
26
27
|
@method = :search_for_ids
|
27
28
|
end
|
28
29
|
|
30
|
+
When /^I use index (.+)$/ do |index|
|
31
|
+
@results = nil
|
32
|
+
@options[:index] = index
|
33
|
+
end
|
34
|
+
|
29
35
|
When /^I am retrieving the result count$/ do
|
30
36
|
@result = nil
|
31
37
|
@method = @model ? :search_count : :count
|
@@ -50,6 +56,10 @@ When /^I search for (\w+) on (\w+)$/ do |query, field|
|
|
50
56
|
@conditions[field.to_sym] = query
|
51
57
|
end
|
52
58
|
|
59
|
+
When /^I output the raw result data$/ do
|
60
|
+
puts results.results.inspect
|
61
|
+
end
|
62
|
+
|
53
63
|
When /^I clear existing filters$/ do
|
54
64
|
@with = {}
|
55
65
|
@without = {}
|
@@ -144,7 +154,7 @@ Then /^I can iterate by result and (\w+)$/ do |attribute|
|
|
144
154
|
iteration = lambda { |result, attr_value|
|
145
155
|
result.should be_kind_of(@model)
|
146
156
|
unless attribute == "group" && attr_value.nil?
|
147
|
-
attr_value.should be_kind_of(Integer)
|
157
|
+
attr_value.should be_kind_of(Integer)
|
148
158
|
end
|
149
159
|
}
|
150
160
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
When
|
1
|
+
When /^I am requesting facet results$/ do
|
2
2
|
@results = nil
|
3
3
|
@method = :facets
|
4
4
|
end
|
@@ -87,6 +87,10 @@ Then /^the ([\w_\s]+) facet should have an? (\d+\.?\d*) key$/ do |name, key|
|
|
87
87
|
results[facet_name(name)].keys.should include(key)
|
88
88
|
end
|
89
89
|
|
90
|
+
Then /^the ([\w\s]+) facet should have (\d+) keys$/ do |name, count|
|
91
|
+
results[facet_name(name)].keys.length.should == count.to_i
|
92
|
+
end
|
93
|
+
|
90
94
|
def facet_name(string)
|
91
95
|
string.gsub(/\s/, '').underscore.to_sym
|
92
96
|
end
|
@@ -18,6 +18,14 @@ When "I stop Sphinx" do
|
|
18
18
|
ThinkingSphinx::Configuration.instance.controller.stop
|
19
19
|
end
|
20
20
|
|
21
|
+
When /^I (enable|disable) delta updates$/ do |mode|
|
22
|
+
ThinkingSphinx.deltas_enabled = (mode == 'enable')
|
23
|
+
end
|
24
|
+
|
25
|
+
When /^I process the (\w+) index$/ do |index|
|
26
|
+
ThinkingSphinx::Configuration.instance.controller.index index
|
27
|
+
end
|
28
|
+
|
21
29
|
Then /^Sphinx should be running/ do
|
22
30
|
ThinkingSphinx.sphinx_running?.should be_true
|
23
31
|
end
|
@@ -25,7 +33,3 @@ end
|
|
25
33
|
Then "Sphinx should not be running" do
|
26
34
|
ThinkingSphinx.sphinx_running?.should be_false
|
27
35
|
end
|
28
|
-
|
29
|
-
When /^I (enable|disable) delta updates$/ do |mode|
|
30
|
-
ThinkingSphinx.deltas_enabled = (mode == 'enable')
|
31
|
-
end
|
@@ -12,3 +12,8 @@ Feature: Searching via STI model relationships
|
|
12
12
|
Given Sphinx is running
|
13
13
|
And I am searching on cats
|
14
14
|
Then I should get as many results as there are cats
|
15
|
+
|
16
|
+
Scenario: Searching across super and subclass indexes
|
17
|
+
Given Sphinx is running
|
18
|
+
When I search for "fantastic"
|
19
|
+
Then I should get 1 result
|
File without changes
|
@@ -0,0 +1,4 @@
|
|
1
|
+
pop = Genre.create(:name => "Pop")
|
2
|
+
Music.create :artist => "Gotye", :album => "Like Drawing Blood", :track => "Heart's A Mess", :genre => pop
|
3
|
+
Music.create :artist => "The Whitlams", :album => "Eternal Nightcap", :track => "Melbourne", :genre => pop
|
4
|
+
Music.create :artist => "Ben Folds", :album => "Ben Folds Live", :track => "Not The Same", :genre => pop
|
@@ -1,6 +1,7 @@
|
|
1
1
|
ActiveRecord::Base.connection.create_table :alphas, :force => true do |t|
|
2
2
|
t.column :name, :string, :null => false
|
3
3
|
t.column :value, :integer, :null => false
|
4
|
+
t.column :active, :boolean, :null => false, :default => true
|
4
5
|
t.column :cost, :decimal, :precision => 10, :scale => 6
|
5
6
|
t.column :created_on, :date
|
6
7
|
t.column :created_at, :timestamp
|
@@ -1,5 +1,4 @@
|
|
1
|
-
ActiveRecord::Base.connection.create_table :robots, :
|
2
|
-
t.column :alternate_primary_key, "int(11) DEFAULT NULL auto_increment PRIMARY KEY"
|
1
|
+
ActiveRecord::Base.connection.create_table :robots, :primary_key => :alternate_primary_key, :force => true do |t|
|
3
2
|
t.column :name, :string, :null => false
|
4
3
|
t.column :internal_id, :string, :null => false
|
5
4
|
end
|
data/features/support/env.rb
CHANGED
@@ -3,4 +3,19 @@ require 'cucumber'
|
|
3
3
|
require 'spec'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'ginger'
|
6
|
-
require 'will_paginate'
|
6
|
+
require 'will_paginate'
|
7
|
+
require 'active_record'
|
8
|
+
|
9
|
+
$:.unshift File.dirname(__FILE__) + '/../../lib'
|
10
|
+
Dir[File.join(File.dirname(__FILE__), '../../vendor/*/lib')].each do |path|
|
11
|
+
$:.unshift path
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'cucumber/thinking_sphinx/internal_world'
|
15
|
+
|
16
|
+
world = Cucumber::ThinkingSphinx::InternalWorld.new
|
17
|
+
world.configure_database
|
18
|
+
|
19
|
+
require "thinking_sphinx"
|
20
|
+
|
21
|
+
world.setup
|
@@ -4,7 +4,19 @@ class Alpha < ActiveRecord::Base
|
|
4
4
|
|
5
5
|
has value, created_at, created_on
|
6
6
|
has cost, :facet => true
|
7
|
+
has active
|
7
8
|
|
8
9
|
set_property :field_weights => {"name" => 10}
|
9
10
|
end
|
11
|
+
|
12
|
+
define_index 'alternative' do
|
13
|
+
indexes :name, :as => :alternative_name, :sortable => true
|
14
|
+
|
15
|
+
has value, created_at, created_on
|
16
|
+
has cost, :facet => true
|
17
|
+
|
18
|
+
set_property :field_weights => {'alternative_name' => 10}
|
19
|
+
|
20
|
+
where "value > 3"
|
21
|
+
end
|
10
22
|
end
|