thinking-sphinx 1.2.13 → 1.4.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.
Files changed (204) hide show
  1. data/README.textile +37 -4
  2. data/VERSION +1 -0
  3. data/features/abstract_inheritance.feature +10 -0
  4. data/features/alternate_primary_key.feature +1 -1
  5. data/features/attribute_updates.feature +49 -5
  6. data/features/deleting_instances.feature +3 -0
  7. data/features/excerpts.feature +8 -0
  8. data/features/facets.feature +15 -1
  9. data/features/facets_across_model.feature +2 -2
  10. data/features/field_sorting.feature +18 -0
  11. data/features/handling_edits.feature +1 -1
  12. data/features/searching_across_models.feature +2 -2
  13. data/features/searching_by_index.feature +40 -0
  14. data/features/searching_by_model.feature +1 -8
  15. data/features/sphinx_scopes.feature +33 -0
  16. data/features/step_definitions/alpha_steps.rb +14 -1
  17. data/features/step_definitions/beta_steps.rb +1 -1
  18. data/features/step_definitions/common_steps.rb +21 -2
  19. data/features/step_definitions/facet_steps.rb +4 -0
  20. data/features/step_definitions/scope_steps.rb +8 -0
  21. data/features/step_definitions/search_steps.rb +5 -0
  22. data/features/step_definitions/sphinx_steps.rb +8 -4
  23. data/features/sti_searching.feature +5 -0
  24. data/features/support/env.rb +7 -6
  25. data/features/{support → thinking_sphinx}/db/fixtures/betas.rb +1 -0
  26. data/features/{support → thinking_sphinx}/db/fixtures/comments.rb +1 -1
  27. data/features/{support → thinking_sphinx}/db/fixtures/developers.rb +2 -0
  28. data/features/thinking_sphinx/db/fixtures/foxes.rb +3 -0
  29. data/features/thinking_sphinx/db/fixtures/music.rb +4 -0
  30. data/features/{support → thinking_sphinx}/db/fixtures/people.rb +1 -1
  31. data/features/{support → thinking_sphinx}/db/fixtures/tags.rb +1 -1
  32. data/features/{support → thinking_sphinx}/db/migrations/create_alphas.rb +1 -0
  33. data/features/{support → thinking_sphinx}/db/migrations/create_developers.rb +0 -2
  34. data/features/thinking_sphinx/db/migrations/create_genres.rb +3 -0
  35. data/features/thinking_sphinx/db/migrations/create_music.rb +6 -0
  36. data/features/thinking_sphinx/models/alpha.rb +23 -0
  37. data/features/thinking_sphinx/models/andrew.rb +17 -0
  38. data/features/{support → thinking_sphinx}/models/beta.rb +1 -1
  39. data/features/{support → thinking_sphinx}/models/developer.rb +2 -2
  40. data/features/{support → thinking_sphinx}/models/extensible_beta.rb +1 -1
  41. data/features/thinking_sphinx/models/fox.rb +5 -0
  42. data/features/thinking_sphinx/models/genre.rb +3 -0
  43. data/features/thinking_sphinx/models/medium.rb +5 -0
  44. data/features/thinking_sphinx/models/music.rb +8 -0
  45. data/features/{support → thinking_sphinx}/models/person.rb +2 -1
  46. data/features/{support → thinking_sphinx}/models/post.rb +2 -1
  47. data/lib/cucumber/thinking_sphinx/external_world.rb +12 -0
  48. data/lib/cucumber/thinking_sphinx/internal_world.rb +13 -11
  49. data/lib/thinking_sphinx/active_record/attribute_updates.rb +17 -15
  50. data/lib/thinking_sphinx/active_record/delta.rb +0 -26
  51. data/lib/thinking_sphinx/active_record/has_many_association.rb +34 -11
  52. data/lib/thinking_sphinx/active_record/scopes.rb +46 -3
  53. data/lib/thinking_sphinx/active_record.rb +271 -193
  54. data/lib/thinking_sphinx/adapters/abstract_adapter.rb +45 -9
  55. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +5 -1
  56. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +9 -1
  57. data/lib/thinking_sphinx/attribute.rb +67 -23
  58. data/lib/thinking_sphinx/auto_version.rb +24 -0
  59. data/lib/thinking_sphinx/bundled_search.rb +44 -0
  60. data/lib/thinking_sphinx/class_facet.rb +3 -2
  61. data/lib/thinking_sphinx/configuration.rb +78 -64
  62. data/lib/thinking_sphinx/context.rb +76 -0
  63. data/lib/thinking_sphinx/deltas/default_delta.rb +14 -20
  64. data/lib/thinking_sphinx/deltas.rb +0 -2
  65. data/lib/thinking_sphinx/deploy/capistrano.rb +1 -1
  66. data/lib/thinking_sphinx/excerpter.rb +1 -1
  67. data/lib/thinking_sphinx/facet.rb +6 -5
  68. data/lib/thinking_sphinx/facet_search.rb +54 -24
  69. data/lib/thinking_sphinx/field.rb +2 -4
  70. data/lib/thinking_sphinx/index/builder.rb +36 -20
  71. data/lib/thinking_sphinx/index/faux_column.rb +8 -0
  72. data/lib/thinking_sphinx/index.rb +77 -19
  73. data/lib/thinking_sphinx/join.rb +37 -0
  74. data/lib/thinking_sphinx/property.rb +9 -2
  75. data/lib/thinking_sphinx/rails_additions.rb +4 -4
  76. data/lib/thinking_sphinx/search.rb +212 -66
  77. data/lib/thinking_sphinx/search_methods.rb +22 -4
  78. data/lib/thinking_sphinx/source/internal_properties.rb +2 -2
  79. data/lib/thinking_sphinx/source/sql.rb +5 -3
  80. data/lib/thinking_sphinx/source.rb +21 -12
  81. data/lib/thinking_sphinx/tasks.rb +26 -58
  82. data/lib/thinking_sphinx/test.rb +55 -0
  83. data/lib/thinking_sphinx.rb +70 -38
  84. data/rails/init.rb +4 -2
  85. data/spec/{lib/thinking_sphinx → thinking_sphinx}/active_record/delta_spec.rb +6 -8
  86. data/spec/{lib/thinking_sphinx → thinking_sphinx}/active_record/has_many_association_spec.rb +26 -3
  87. data/spec/thinking_sphinx/active_record/scopes_spec.rb +176 -0
  88. data/spec/thinking_sphinx/active_record_spec.rb +618 -0
  89. data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +134 -0
  90. data/spec/{lib/thinking_sphinx → thinking_sphinx}/association_spec.rb +1 -1
  91. data/spec/{lib/thinking_sphinx → thinking_sphinx}/attribute_spec.rb +87 -46
  92. data/spec/thinking_sphinx/auto_version_spec.rb +47 -0
  93. data/spec/{lib/thinking_sphinx → thinking_sphinx}/configuration_spec.rb +73 -63
  94. data/spec/thinking_sphinx/context_spec.rb +127 -0
  95. data/spec/{lib/thinking_sphinx → thinking_sphinx}/core/array_spec.rb +1 -1
  96. data/spec/{lib/thinking_sphinx → thinking_sphinx}/core/string_spec.rb +1 -1
  97. data/spec/{lib/thinking_sphinx → thinking_sphinx}/excerpter_spec.rb +1 -9
  98. data/spec/{lib/thinking_sphinx → thinking_sphinx}/facet_search_spec.rb +76 -82
  99. data/spec/{lib/thinking_sphinx → thinking_sphinx}/facet_spec.rb +5 -5
  100. data/spec/{lib/thinking_sphinx → thinking_sphinx}/field_spec.rb +1 -42
  101. data/spec/{lib/thinking_sphinx → thinking_sphinx}/index/builder_spec.rb +71 -31
  102. data/spec/{lib/thinking_sphinx → thinking_sphinx}/index/faux_column_spec.rb +8 -2
  103. data/spec/thinking_sphinx/index_spec.rb +183 -0
  104. data/spec/{lib/thinking_sphinx → thinking_sphinx}/rails_additions_spec.rb +5 -5
  105. data/spec/{lib/thinking_sphinx → thinking_sphinx}/search_methods_spec.rb +5 -1
  106. data/spec/{lib/thinking_sphinx → thinking_sphinx}/search_spec.rb +183 -31
  107. data/spec/{lib/thinking_sphinx → thinking_sphinx}/source_spec.rb +18 -2
  108. data/spec/thinking_sphinx/test_spec.rb +20 -0
  109. data/spec/thinking_sphinx_spec.rb +204 -0
  110. data/tasks/distribution.rb +7 -26
  111. data/tasks/testing.rb +32 -20
  112. metadata +488 -147
  113. data/VERSION.yml +0 -5
  114. data/features/datetime_deltas.feature +0 -66
  115. data/features/delayed_delta_indexing.feature +0 -37
  116. data/features/step_definitions/datetime_delta_steps.rb +0 -15
  117. data/features/step_definitions/delayed_delta_indexing_steps.rb +0 -7
  118. data/features/support/database.yml +0 -5
  119. data/features/support/db/active_record.rb +0 -40
  120. data/features/support/db/database.yml +0 -5
  121. data/features/support/db/fixtures/delayed_betas.rb +0 -10
  122. data/features/support/db/fixtures/thetas.rb +0 -10
  123. data/features/support/db/migrations/create_delayed_betas.rb +0 -17
  124. data/features/support/db/migrations/create_thetas.rb +0 -5
  125. data/features/support/db/mysql.rb +0 -3
  126. data/features/support/db/postgresql.rb +0 -3
  127. data/features/support/models/alpha.rb +0 -10
  128. data/features/support/models/delayed_beta.rb +0 -7
  129. data/features/support/models/theta.rb +0 -7
  130. data/features/support/post_database.rb +0 -43
  131. data/lib/thinking_sphinx/deltas/datetime_delta.rb +0 -50
  132. data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +0 -24
  133. data/lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb +0 -27
  134. data/lib/thinking_sphinx/deltas/delayed_delta/job.rb +0 -26
  135. data/lib/thinking_sphinx/deltas/delayed_delta.rb +0 -30
  136. data/spec/lib/thinking_sphinx/active_record/scopes_spec.rb +0 -96
  137. data/spec/lib/thinking_sphinx/active_record_spec.rb +0 -353
  138. data/spec/lib/thinking_sphinx/deltas/job_spec.rb +0 -32
  139. data/spec/lib/thinking_sphinx/index_spec.rb +0 -45
  140. data/spec/lib/thinking_sphinx_spec.rb +0 -162
  141. data/vendor/after_commit/LICENSE +0 -20
  142. data/vendor/after_commit/README +0 -16
  143. data/vendor/after_commit/Rakefile +0 -22
  144. data/vendor/after_commit/init.rb +0 -8
  145. data/vendor/after_commit/lib/after_commit/active_record.rb +0 -114
  146. data/vendor/after_commit/lib/after_commit/connection_adapters.rb +0 -103
  147. data/vendor/after_commit/lib/after_commit.rb +0 -45
  148. data/vendor/after_commit/test/after_commit_test.rb +0 -53
  149. data/vendor/delayed_job/lib/delayed/job.rb +0 -251
  150. data/vendor/delayed_job/lib/delayed/message_sending.rb +0 -7
  151. data/vendor/delayed_job/lib/delayed/performable_method.rb +0 -55
  152. data/vendor/delayed_job/lib/delayed/worker.rb +0 -54
  153. data/vendor/riddle/lib/riddle/client/filter.rb +0 -53
  154. data/vendor/riddle/lib/riddle/client/message.rb +0 -66
  155. data/vendor/riddle/lib/riddle/client/response.rb +0 -84
  156. data/vendor/riddle/lib/riddle/client.rb +0 -635
  157. data/vendor/riddle/lib/riddle/configuration/distributed_index.rb +0 -48
  158. data/vendor/riddle/lib/riddle/configuration/index.rb +0 -142
  159. data/vendor/riddle/lib/riddle/configuration/indexer.rb +0 -19
  160. data/vendor/riddle/lib/riddle/configuration/remote_index.rb +0 -17
  161. data/vendor/riddle/lib/riddle/configuration/searchd.rb +0 -25
  162. data/vendor/riddle/lib/riddle/configuration/section.rb +0 -43
  163. data/vendor/riddle/lib/riddle/configuration/source.rb +0 -23
  164. data/vendor/riddle/lib/riddle/configuration/sql_source.rb +0 -34
  165. data/vendor/riddle/lib/riddle/configuration/xml_source.rb +0 -28
  166. data/vendor/riddle/lib/riddle/configuration.rb +0 -33
  167. data/vendor/riddle/lib/riddle/controller.rb +0 -53
  168. data/vendor/riddle/lib/riddle.rb +0 -30
  169. data/features/{support → thinking_sphinx}/database.example.yml +0 -0
  170. data/features/{support → thinking_sphinx}/db/fixtures/alphas.rb +0 -0
  171. data/features/{support → thinking_sphinx}/db/fixtures/authors.rb +0 -0
  172. data/features/{support → thinking_sphinx}/db/fixtures/boxes.rb +0 -0
  173. data/features/{support → thinking_sphinx}/db/fixtures/categories.rb +0 -0
  174. data/features/{support → thinking_sphinx}/db/fixtures/cats.rb +0 -0
  175. data/features/{support → thinking_sphinx}/db/fixtures/dogs.rb +0 -0
  176. data/features/{support → thinking_sphinx}/db/fixtures/extensible_betas.rb +0 -0
  177. data/features/{support → thinking_sphinx}/db/fixtures/gammas.rb +0 -0
  178. data/features/{support → thinking_sphinx}/db/fixtures/posts.rb +0 -0
  179. data/features/{support → thinking_sphinx}/db/fixtures/robots.rb +0 -0
  180. data/features/{support → thinking_sphinx}/db/migrations/create_animals.rb +0 -0
  181. data/features/{support → thinking_sphinx}/db/migrations/create_authors.rb +0 -0
  182. data/features/{support → thinking_sphinx}/db/migrations/create_authors_posts.rb +0 -0
  183. data/features/{support → thinking_sphinx}/db/migrations/create_betas.rb +0 -0
  184. data/features/{support → thinking_sphinx}/db/migrations/create_boxes.rb +0 -0
  185. data/features/{support → thinking_sphinx}/db/migrations/create_categories.rb +0 -0
  186. data/features/{support → thinking_sphinx}/db/migrations/create_comments.rb +0 -0
  187. data/features/{support → thinking_sphinx}/db/migrations/create_extensible_betas.rb +0 -0
  188. data/features/{support → thinking_sphinx}/db/migrations/create_gammas.rb +0 -0
  189. data/features/{support → thinking_sphinx}/db/migrations/create_people.rb +0 -0
  190. data/features/{support → thinking_sphinx}/db/migrations/create_posts.rb +0 -0
  191. data/features/{support → thinking_sphinx}/db/migrations/create_robots.rb +0 -0
  192. data/features/{support → thinking_sphinx}/db/migrations/create_taggings.rb +0 -0
  193. data/features/{support → thinking_sphinx}/db/migrations/create_tags.rb +0 -0
  194. data/features/{support → thinking_sphinx}/models/animal.rb +0 -0
  195. data/features/{support → thinking_sphinx}/models/author.rb +0 -0
  196. data/features/{support → thinking_sphinx}/models/box.rb +0 -0
  197. data/features/{support → thinking_sphinx}/models/cat.rb +0 -0
  198. data/features/{support → thinking_sphinx}/models/category.rb +0 -0
  199. data/features/{support → thinking_sphinx}/models/comment.rb +3 -3
  200. /data/features/{support → thinking_sphinx}/models/dog.rb +0 -0
  201. /data/features/{support → thinking_sphinx}/models/gamma.rb +0 -0
  202. /data/features/{support → thinking_sphinx}/models/robot.rb +0 -0
  203. /data/features/{support → thinking_sphinx}/models/tag.rb +0 -0
  204. /data/features/{support → thinking_sphinx}/models/tagging.rb +0 -0
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
- sudo gem install ginger --source http://gemcutter.org
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
- sudo gem install cucumber yard jeweler rspec
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
- cp spec/fixtures/database.yml.default spec/fixtures/database.yml
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,28 @@ 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
162
+ * Amir Yalon
163
+ * Edgars Beigarts
164
+ * Ivan Ukhov
165
+ * Tomáš Pospíšek
166
+ * Tom Stuart
167
+ * James Brooks
168
+ * Mark Dodwell
169
+ * Frédéric Malamitsas
170
+ * Jon Gubman
171
+ * Michael Schuerig
172
+ * Ben Hutton
173
+ * Alfonso Jiménez
174
+ * Szymon Nowak
175
+ * Keith Pitt
176
+ * Lee Capps
177
+ * Sam Goldstein
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.4.0
@@ -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
@@ -23,5 +23,5 @@ Feature: Searching on a single model
23
23
 
24
24
  When I destroy robot Expendable
25
25
  And I wait for Sphinx to catch up
26
- And I search for three
26
+ And I search for Expendable
27
27
  Then I should get 0 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 two to 13
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 two to 3
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
@@ -26,8 +32,46 @@ Feature: Update attributes directly to Sphinx
26
32
  Then I should get 1 result
27
33
 
28
34
  When I change the value of beta eight to 18
35
+ And I wait for Sphinx to catch up
29
36
  And I filter by 18 on value
30
37
  Then I should get 1 result
31
38
 
32
39
  When I search for the document id of beta eight in the beta_delta index
33
- Then it should not exist
40
+ Then it should not exist
41
+
42
+ Scenario: Updating attributes in a delta index
43
+ Given Sphinx is running
44
+ And I am searching on betas
45
+
46
+ When I change the name of beta nine to nineteen
47
+ And I change the value of beta nineteen to 19
48
+ And I wait for Sphinx to catch up
49
+
50
+ When I filter by 19 on value
51
+ And I use index beta_delta
52
+ Then I should get 1 result
53
+
54
+ Scenario: Updating attributes in a delta index with deltas disabled
55
+ Given Sphinx is running
56
+ And I am searching on betas
57
+
58
+ When I change the name of beta eleven to twentyone
59
+ And I disable delta updates
60
+ And I change the value of beta twentyone to 21
61
+ And I wait for Sphinx to catch up
62
+
63
+ When I filter by 21 on value
64
+ And I use index beta_delta
65
+ Then I should get 1 result
66
+ And I enable delta updates
67
+
68
+ Scenario: Updating boolean attribute in Sphinx
69
+ Given Sphinx is running
70
+ And I am searching on alphas
71
+ When I filter by active alphas
72
+ Then I should get 10 results
73
+
74
+ When I flag alpha five as inactive
75
+ And I wait for Sphinx to catch up
76
+ And I filter by active alphas
77
+ 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
@@ -11,3 +11,11 @@ Feature: Generate excerpts for search results
11
11
  And I am searching on comments
12
12
  And I search for "lorem"
13
13
  Then calling content on the first result excerpts object should return "de un sitio mientras que mira su diseño. El punto de usar <span class="match">Lorem</span> Ipsum es que tiene una distribución"
14
+
15
+ Scenario: Excerpt Options
16
+ Given Sphinx is running
17
+ And I am searching on comments
18
+ And I search for "lorem"
19
+ And I provide excerpt option "before_match" with value "<em>"
20
+ And I provide excerpt option "after_match" with value "</em>"
21
+ Then calling content on the first result excerpts object should return "de un sitio mientras que mira su diseño. El punto de usar <em>Lorem</em> Ipsum es que tiene una distribución"
@@ -27,7 +27,7 @@ Feature: Search and browse models by their defined facets
27
27
  And I should have the facet State
28
28
  And I should have the facet Age
29
29
 
30
- Scenario: Requseting float facets
30
+ Scenario: Requesting float facets
31
31
  Given Sphinx is running
32
32
  And I am searching on alphas
33
33
  When I am requesting facet results
@@ -74,3 +74,17 @@ 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
83
+
84
+ Scenario: Requesting facets from a subclass
85
+ Given Sphinx is running
86
+ And I am searching on animals
87
+ When I am requesting facet results
88
+ And I want classes included
89
+ Then I should have the facet Class
90
+
@@ -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 10 facets
8
+ And I should have 12 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 9 facets
22
+ Then I should have 11 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,18 @@
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
+
@@ -14,7 +14,7 @@ Feature: Keeping Sphinx in line with model changes when requested
14
14
  And I search for two
15
15
  Then I should get 1 result
16
16
 
17
- Scenario: Not returing an instance from old data if there is a delta
17
+ Scenario: Not returning an instance from old data if there is a delta
18
18
  Given Sphinx is running
19
19
  And I am searching on betas
20
20
  When I search for two
@@ -7,7 +7,7 @@ Feature: Searching across multiple model
7
7
  Given Sphinx is running
8
8
  When I search for James
9
9
  And I am retrieving the result count
10
- Then I should get a value of 3
10
+ Then I should get a value of 6
11
11
 
12
12
  Scenario: Confirming existance of a document id in a given index
13
13
  Given Sphinx is running
@@ -17,4 +17,4 @@ Feature: Searching across multiple model
17
17
  Scenario: Retrieving results from multiple models
18
18
  Given Sphinx is running
19
19
  When I search for ten
20
- Then I should get 6 results
20
+ Then I should get 4 results
@@ -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
@@ -63,7 +63,7 @@ Feature: Searching on a single model
63
63
  Scenario: Filtering on timestamp MVAs
64
64
  Given Sphinx is running
65
65
  And I am searching on posts
66
- When I filter by 978307200 on comments_created_at
66
+ When I filter by 2001-01-01 on comments_created_at
67
67
  Then I should get 1 result
68
68
 
69
69
  Scenario: Searching by NULL/0 values in MVAs
@@ -97,13 +97,6 @@ Feature: Searching on a single model
97
97
  Then I should get 10 results
98
98
  And the value of each result should indicate order
99
99
 
100
- Scenario: Searching with ordering on a sortable field
101
- Given Sphinx is running
102
- And I am searching on people
103
- And I order by first_name
104
- Then I should get 20 results
105
- And the first_name of each result should indicate order
106
-
107
100
  Scenario: Intepreting Sphinx Internal Identifiers
108
101
  Given Sphinx is running
109
102
  And I am searching on people
@@ -33,3 +33,36 @@ 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
43
+
44
+ Scenario: Counts with scopes and additional query terms
45
+ Given Sphinx is running
46
+ And I am searching on people
47
+ When I use the with_first_name scope set to "Andrew"
48
+ And I am retrieving the scoped result count for "Byrne"
49
+ Then I should get a value of 1
50
+
51
+ Scenario: Default Scope
52
+ Given Sphinx is running
53
+ And I am searching on andrews
54
+ Then I should get 7 results
55
+
56
+ Scenario: Default Scope and additional query terms
57
+ Given Sphinx is running
58
+ And I am searching on andrews
59
+ When I search for "Byrne"
60
+ Then I should get 1 result
61
+
62
+ Scenario: Explicit scope plus search over a default scope
63
+ Given Sphinx is running
64
+ And I am searching on andrews
65
+ When I use the locked_last_name scope
66
+ And I search for "Cecil"
67
+ Then I should get 1 result
68
+
@@ -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,5 +1,5 @@
1
1
  When /^I create a new beta named (\w+)$/ do |name|
2
- Beta.create(:name => name, :value => 101)
2
+ Beta.create!(:name => name, :value => 101)
3
3
  end
4
4
 
5
5
  When /^I change the (\w+) of beta (\w+) to (\w+)$/ do |column, name, replacement|
@@ -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 = {}
@@ -61,6 +71,11 @@ When /^I filter by (\w+) on (\w+)$/ do |filter, attribute|
61
71
  @with[attribute.to_sym] = filter.to_i
62
72
  end
63
73
 
74
+ When /^I filter by (\d\d\d\d)\-(\d\d)\-(\d\d) on (\w+)$/ do |y, m, d, attribute|
75
+ @results = nil
76
+ @with[attribute.to_sym] = Time.local(y.to_i, m.to_i, d.to_i).to_i
77
+ end
78
+
64
79
  When /^I filter by (\d+) and (\d+) on (\w+)$/ do |value_one, value_two, attribute|
65
80
  @results = nil
66
81
  @with[attribute.to_sym] = [value_one.to_i, value_two.to_i]
@@ -140,11 +155,15 @@ Then /^the (\w+) of each result should indicate order$/ do |attribute|
140
155
  end
141
156
  end
142
157
 
158
+ Then /^the first result's "([^"]*)" should be "([^"]*)"$/ do |attribute, value|
159
+ results.first.send(attribute.to_sym).should == value
160
+ end
161
+
143
162
  Then /^I can iterate by result and (\w+)$/ do |attribute|
144
163
  iteration = lambda { |result, attr_value|
145
164
  result.should be_kind_of(@model)
146
165
  unless attribute == "group" && attr_value.nil?
147
- attr_value.should be_kind_of(Integer)
166
+ attr_value.should be_kind_of(Integer)
148
167
  end
149
168
  }
150
169
 
@@ -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
@@ -9,3 +9,11 @@ end
9
9
  When /^I use the ([\w]+) scope set to (\d+)$/ do |scope, int|
10
10
  @results = results.send(scope.to_sym, int.to_i)
11
11
  end
12
+
13
+ When /^I am retrieving the scoped result count$/ do
14
+ @results = results.search_count
15
+ end
16
+
17
+ When /^I am retrieving the scoped result count for "([^"]*)"$/ do |query|
18
+ @results = results.search_count query
19
+ end
@@ -87,3 +87,8 @@ end
87
87
  Then /^the first result should have a (\w+\s?\w*) of (\d+)$/ do |attribute, value|
88
88
  results.first.sphinx_attributes[attribute.gsub(/\s+/, '_')].should == value.to_i
89
89
  end
90
+
91
+ Given /^I provide excerpt option "([a-z_]*)" with value "([^"]*)"$/ do |k, v|
92
+ @options[:excerpt_options] ||= {}
93
+ @options[:excerpt_options][k.to_sym] = v
94
+ 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
@@ -1,18 +1,19 @@
1
1
  require 'rubygems'
2
- require 'cucumber'
3
- require 'spec'
4
2
  require 'fileutils'
5
- require 'ginger'
6
- require 'will_paginate'
7
- require 'active_record'
3
+ require 'bundler'
4
+
5
+ Bundler.require :default, :development
8
6
 
9
7
  $:.unshift File.dirname(__FILE__) + '/../../lib'
8
+ Dir[File.join(File.dirname(__FILE__), '../../vendor/*/lib')].each do |path|
9
+ $:.unshift path
10
+ end
10
11
 
11
12
  require 'cucumber/thinking_sphinx/internal_world'
12
13
 
13
14
  world = Cucumber::ThinkingSphinx::InternalWorld.new
14
15
  world.configure_database
15
16
 
16
- require 'thinking_sphinx'
17
+ require "thinking_sphinx"
17
18
 
18
19
  world.setup
@@ -8,3 +8,4 @@ Beta.create :name => "seven", :value => 7
8
8
  Beta.create :name => "eight", :value => 8
9
9
  Beta.create :name => "nine", :value => 9
10
10
  Beta.create :name => "ten", :value => 10
11
+ Beta.create :name => "eleven", :value => 11
@@ -4,7 +4,7 @@ Comment.create(
4
4
  :content => "+1",
5
5
  :post_id => 1,
6
6
  :category_id => 1
7
- ).update_attribute(:created_at, Time.utc(2001, 01, 01))
7
+ ).update_attribute(:created_at, Time.local(2001, 01, 01).getutc)
8
8
 
9
9
  Comment.create(
10
10
  :name => "Menno",
@@ -1,3 +1,5 @@
1
+ require 'faker'
2
+
1
3
  Developer.create :name => "Pat Allan", :city => "Melbourne", :state => "Victoria", :country => "Australia", :age => 26
2
4
 
3
5
  2.times do
@@ -0,0 +1,3 @@
1
+ %w( fantastic ).each do |name|
2
+ Fox.create :name => name
3
+ end
@@ -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
@@ -18,7 +18,7 @@ Person.create :gender => "male", :first_name => "Peter", :middle_initial => "C",
18
18
  Person.create :gender => "female", :first_name => "Hollie", :middle_initial => "C", :last_name => "Hunter", :street_address => "34 Cornish Street", :city => "Kensington", :state => "VIC", :postcode => "3031", :email => "Hollie.C.Hunter@mailinator.com", :birthday => "1954/2/16 00:00:00"
19
19
  Person.create :gender => "male", :first_name => "Jonathan", :middle_initial => "C", :last_name => "Turner", :street_address => "2 Kopkes Road", :city => "Carngham", :state => "VIC", :postcode => "3351", :email => "Jonathan.C.Turner@trashymail.com", :birthday => "1963/8/26 00:00:00"
20
20
  Person.create :gender => "female", :first_name => "Kate", :middle_initial => "S", :last_name => "Doyle", :street_address => "42 Gregory Way", :city => "Mungalup", :state => "WA", :postcode => "6225", :email => "Kate.S.Doyle@mailinator.com", :birthday => "1974/1/5 00:00:00"
21
- Person.create :gender => "male", :first_name => "Harley", :middle_initial => "M", :last_name => "Abbott", :street_address => "39 Faulkner Street", :city => "Tilbuster", :state => "NSW", :postcode => "2350", :email => "Harley.M.Abbott@trashymail.com", :birthday => "1953/10/4 00:00:00"
21
+ Person.create :gender => "male", :first_name => "Harley", :middle_initial => "M", :last_name => "abbott", :street_address => "39 Faulkner Street", :city => "Tilbuster", :state => "NSW", :postcode => "2350", :email => "Harley.M.Abbott@trashymail.com", :birthday => "1953/10/4 00:00:00"
22
22
  Person.create :gender => "male", :first_name => "Morgan", :middle_initial => "E", :last_name => "Iqbal", :street_address => "64 Carlisle Street", :city => "Dysart", :state => "VIC", :postcode => "3660", :email => "Morgan.E.Iqbal@spambob.com", :birthday => "1954/7/6 00:00:00"
23
23
  Person.create :gender => "female", :first_name => "Phoebe", :middle_initial => "T", :last_name => "Wells", :street_address => "10 Mnimbah Road", :city => "Eccleston", :state => "NSW", :postcode => "2311", :email => "Phoebe.T.Wells@trashymail.com", :birthday => "1949/5/27 00:00:00"
24
24
  Person.create :gender => "male", :first_name => "Finley", :middle_initial => "I", :last_name => "Martin", :street_address => "15 Thomas Lane", :city => "Epping", :state => "VIC", :postcode => "3076", :email => "Finley.I.Martin@dodgit.com", :birthday => "1983/3/12 00:00:00"
@@ -24,4 +24,4 @@ Developer.find(:all).each do |developer|
24
24
  end
25
25
  end
26
26
 
27
- Tagging.create(:taggable => Developer.last)
27
+ Tagging.create(:taggable => Developer.find(:all).last)
@@ -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,3 @@
1
- require 'faker'
2
-
3
1
  ActiveRecord::Base.connection.create_table :developers, :force => true do |t|
4
2
  t.column :name, :string, :null => false
5
3
  t.column :city, :string
@@ -0,0 +1,3 @@
1
+ ActiveRecord::Base.connection.create_table :genres, :force => true do |t|
2
+ t.column :name, :string
3
+ end
@@ -0,0 +1,6 @@
1
+ ActiveRecord::Base.connection.create_table :music, :force => true do |t|
2
+ t.column :artist, :string
3
+ t.column :album, :string
4
+ t.column :track, :string
5
+ t.column :genre_id, :integer
6
+ end