thinking-sphinx 2.1.0 → 3.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (352) hide show
  1. data/.gitignore +8 -0
  2. data/.travis.yml +13 -0
  3. data/Appraisals +7 -0
  4. data/Gemfile +10 -0
  5. data/HISTORY +2 -267
  6. data/LICENCE +1 -1
  7. data/README.textile +194 -226
  8. data/Rakefile +24 -0
  9. data/gemfiles/.gitignore +1 -0
  10. data/gemfiles/rails_3_1.gemfile +11 -0
  11. data/gemfiles/rails_3_2.gemfile +11 -0
  12. data/lib/thinking-sphinx.rb +1 -1
  13. data/lib/thinking_sphinx.rb +34 -292
  14. data/lib/thinking_sphinx/active_record.rb +22 -383
  15. data/lib/thinking_sphinx/active_record/association.rb +9 -0
  16. data/lib/thinking_sphinx/active_record/association_proxy.rb +68 -0
  17. data/lib/thinking_sphinx/active_record/associations.rb +68 -0
  18. data/lib/thinking_sphinx/active_record/attribute.rb +20 -0
  19. data/lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb +32 -0
  20. data/lib/thinking_sphinx/active_record/attribute/type.rb +79 -0
  21. data/lib/thinking_sphinx/active_record/attribute/values.rb +18 -0
  22. data/lib/thinking_sphinx/active_record/base.rb +36 -0
  23. data/lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb +31 -0
  24. data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +55 -0
  25. data/lib/thinking_sphinx/active_record/callbacks/update_callbacks.rb +59 -0
  26. data/lib/thinking_sphinx/active_record/column.rb +30 -0
  27. data/lib/thinking_sphinx/active_record/database_adapters.rb +51 -0
  28. data/lib/thinking_sphinx/active_record/database_adapters/abstract_adapter.rb +13 -0
  29. data/lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb +23 -0
  30. data/lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb +25 -0
  31. data/lib/thinking_sphinx/active_record/field.rb +11 -0
  32. data/lib/thinking_sphinx/active_record/index.rb +55 -0
  33. data/lib/thinking_sphinx/active_record/interpreter.rb +47 -0
  34. data/lib/thinking_sphinx/active_record/log_subscriber.rb +10 -58
  35. data/lib/thinking_sphinx/active_record/property.rb +28 -0
  36. data/lib/thinking_sphinx/active_record/property_sql_presenter.rb +60 -0
  37. data/lib/thinking_sphinx/active_record/sql_builder.rb +159 -0
  38. data/lib/thinking_sphinx/active_record/sql_source.rb +138 -0
  39. data/lib/thinking_sphinx/active_record/sql_source/template.rb +46 -0
  40. data/lib/thinking_sphinx/batched_search.rb +26 -0
  41. data/lib/thinking_sphinx/callbacks.rb +15 -0
  42. data/lib/thinking_sphinx/configuration.rb +80 -331
  43. data/lib/thinking_sphinx/configuration/consistent_ids.rb +31 -0
  44. data/lib/thinking_sphinx/configuration/defaults.rb +5 -0
  45. data/lib/thinking_sphinx/core.rb +6 -0
  46. data/lib/thinking_sphinx/core/index.rb +68 -0
  47. data/lib/thinking_sphinx/core/interpreter.rb +19 -0
  48. data/lib/thinking_sphinx/deltas.rb +35 -26
  49. data/lib/thinking_sphinx/deltas/default_delta.rb +56 -56
  50. data/lib/thinking_sphinx/excerpter.rb +23 -21
  51. data/lib/thinking_sphinx/facet.rb +22 -127
  52. data/lib/thinking_sphinx/facet_search.rb +95 -162
  53. data/lib/thinking_sphinx/index.rb +39 -143
  54. data/lib/thinking_sphinx/index_set.rb +51 -0
  55. data/lib/thinking_sphinx/masks.rb +8 -0
  56. data/lib/thinking_sphinx/masks/group_enumerators_mask.rb +23 -0
  57. data/lib/thinking_sphinx/masks/pagination_mask.rb +60 -0
  58. data/lib/thinking_sphinx/masks/scopes_mask.rb +35 -0
  59. data/lib/thinking_sphinx/masks/weight_enumerator_mask.rb +11 -0
  60. data/lib/thinking_sphinx/middlewares.rb +36 -0
  61. data/lib/thinking_sphinx/middlewares/active_record_translator.rb +73 -0
  62. data/lib/thinking_sphinx/middlewares/geographer.rb +53 -0
  63. data/lib/thinking_sphinx/middlewares/glazier.rb +39 -0
  64. data/lib/thinking_sphinx/middlewares/ids_only.rb +13 -0
  65. data/lib/thinking_sphinx/middlewares/inquirer.rb +62 -0
  66. data/lib/thinking_sphinx/middlewares/middleware.rb +9 -0
  67. data/lib/thinking_sphinx/middlewares/sphinxql.rb +149 -0
  68. data/lib/thinking_sphinx/middlewares/stale_id_checker.rb +45 -0
  69. data/lib/thinking_sphinx/middlewares/stale_id_filter.rb +46 -0
  70. data/lib/thinking_sphinx/panes.rb +8 -0
  71. data/lib/thinking_sphinx/panes/attributes_pane.rb +9 -0
  72. data/lib/thinking_sphinx/panes/distance_pane.rb +13 -0
  73. data/lib/thinking_sphinx/panes/excerpts_pane.rb +37 -0
  74. data/lib/thinking_sphinx/panes/weight_pane.rb +9 -0
  75. data/lib/thinking_sphinx/railtie.rb +6 -40
  76. data/lib/thinking_sphinx/rake_interface.rb +47 -0
  77. data/lib/thinking_sphinx/real_time.rb +11 -0
  78. data/lib/thinking_sphinx/real_time/attribute.rb +5 -0
  79. data/lib/thinking_sphinx/real_time/callbacks/real_time_callbacks.rb +48 -0
  80. data/lib/thinking_sphinx/real_time/field.rb +3 -0
  81. data/lib/thinking_sphinx/real_time/index.rb +47 -0
  82. data/lib/thinking_sphinx/real_time/index/template.rb +33 -0
  83. data/lib/thinking_sphinx/real_time/interpreter.rb +23 -0
  84. data/lib/thinking_sphinx/real_time/property.rb +16 -0
  85. data/lib/thinking_sphinx/scopes.rb +22 -0
  86. data/lib/thinking_sphinx/search.rb +90 -1028
  87. data/lib/thinking_sphinx/search/batch_inquirer.rb +27 -0
  88. data/lib/thinking_sphinx/search/context.rb +26 -0
  89. data/lib/thinking_sphinx/search/glaze.rb +32 -0
  90. data/lib/thinking_sphinx/search/merger.rb +24 -0
  91. data/lib/thinking_sphinx/search/query.rb +43 -0
  92. data/lib/thinking_sphinx/search/stale_ids_exception.rb +11 -0
  93. data/lib/thinking_sphinx/search/translator.rb +50 -0
  94. data/lib/thinking_sphinx/tasks.rb +22 -125
  95. data/lib/thinking_sphinx/test.rb +9 -19
  96. data/sketchpad.rb +58 -0
  97. data/spec/acceptance/association_scoping_spec.rb +23 -0
  98. data/spec/acceptance/attribute_access_spec.rb +39 -0
  99. data/spec/acceptance/attribute_updates_spec.rb +16 -0
  100. data/spec/acceptance/batch_searching_spec.rb +21 -0
  101. data/spec/acceptance/big_integers_spec.rb +27 -0
  102. data/spec/acceptance/excerpts_spec.rb +14 -0
  103. data/spec/acceptance/facets_spec.rb +122 -0
  104. data/spec/acceptance/geosearching_spec.rb +39 -0
  105. data/spec/acceptance/grouping_by_attributes_spec.rb +77 -0
  106. data/spec/acceptance/paginating_search_results_spec.rb +24 -0
  107. data/spec/acceptance/remove_deleted_records_spec.rb +23 -0
  108. data/spec/acceptance/search_counts_spec.rb +18 -0
  109. data/spec/acceptance/search_for_just_ids_spec.rb +19 -0
  110. data/spec/acceptance/searching_across_models_spec.rb +28 -0
  111. data/spec/acceptance/searching_on_fields_spec.rb +56 -0
  112. data/spec/acceptance/searching_with_filters_spec.rb +109 -0
  113. data/spec/acceptance/searching_with_sti_spec.rb +55 -0
  114. data/spec/acceptance/searching_within_a_model_spec.rb +52 -0
  115. data/spec/acceptance/sorting_search_results_spec.rb +41 -0
  116. data/spec/acceptance/spec_helper.rb +4 -0
  117. data/spec/acceptance/specifying_sql_spec.rb +62 -0
  118. data/spec/acceptance/sphinx_scopes_spec.rb +49 -0
  119. data/spec/acceptance/sql_deltas_spec.rb +43 -0
  120. data/spec/acceptance/support/database_cleaner.rb +11 -0
  121. data/spec/acceptance/support/sphinx_controller.rb +39 -0
  122. data/spec/acceptance/support/sphinx_helpers.rb +24 -0
  123. data/spec/acceptance/suspended_deltas_spec.rb +20 -0
  124. data/spec/internal/.gitignore +1 -0
  125. data/spec/internal/app/indices/animal_index.rb +3 -0
  126. data/spec/internal/app/indices/article_index.rb +24 -0
  127. data/spec/internal/app/indices/book_index.rb +8 -0
  128. data/spec/internal/app/indices/city_index.rb +6 -0
  129. data/spec/internal/app/indices/product_index.rb +3 -0
  130. data/spec/internal/app/indices/tee_index.rb +4 -0
  131. data/spec/internal/app/indices/user_index.rb +5 -0
  132. data/spec/internal/app/models/animal.rb +2 -0
  133. data/spec/internal/app/models/article.rb +5 -0
  134. data/spec/internal/app/models/bird.rb +2 -0
  135. data/spec/internal/app/models/book.rb +11 -0
  136. data/spec/internal/app/models/city.rb +2 -0
  137. data/spec/internal/app/models/colour.rb +3 -0
  138. data/spec/internal/app/models/flightless_bird.rb +2 -0
  139. data/spec/internal/app/models/mammal.rb +2 -0
  140. data/spec/internal/app/models/product.rb +3 -0
  141. data/spec/internal/app/models/tag.rb +4 -0
  142. data/{features/thinking_sphinx → spec/internal/app}/models/tagging.rb +1 -1
  143. data/spec/internal/app/models/tee.rb +3 -0
  144. data/spec/internal/app/models/tweet.rb +3 -0
  145. data/spec/internal/app/models/user.rb +3 -0
  146. data/spec/internal/config/database.yml +5 -0
  147. data/spec/internal/db/schema.rb +65 -0
  148. data/spec/internal/log/.gitignore +1 -0
  149. data/spec/spec_helper.rb +8 -49
  150. data/spec/support/sphinx_yaml_helpers.rb +9 -0
  151. data/spec/thinking_sphinx/active_record/association_spec.rb +12 -0
  152. data/spec/thinking_sphinx/active_record/associations_spec.rb +184 -0
  153. data/spec/thinking_sphinx/active_record/attribute/type_spec.rb +147 -0
  154. data/spec/thinking_sphinx/active_record/base_spec.rb +61 -0
  155. data/spec/thinking_sphinx/active_record/callbacks/delete_callbacks_spec.rb +80 -0
  156. data/spec/thinking_sphinx/active_record/callbacks/delta_callbacks_spec.rb +147 -0
  157. data/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +69 -0
  158. data/spec/thinking_sphinx/active_record/column_spec.rb +47 -0
  159. data/spec/thinking_sphinx/active_record/database_adapters/abstract_adapter_spec.rb +31 -0
  160. data/spec/thinking_sphinx/active_record/database_adapters/mysql_adapter_spec.rb +43 -0
  161. data/spec/thinking_sphinx/active_record/database_adapters/postgresql_adapter_spec.rb +45 -0
  162. data/spec/thinking_sphinx/active_record/database_adapters_spec.rb +108 -0
  163. data/spec/thinking_sphinx/active_record/field_spec.rb +36 -0
  164. data/spec/thinking_sphinx/active_record/index_spec.rb +208 -0
  165. data/spec/thinking_sphinx/active_record/interpreter_spec.rb +293 -0
  166. data/spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb +162 -0
  167. data/spec/thinking_sphinx/active_record/sql_builder_spec.rb +666 -0
  168. data/spec/thinking_sphinx/active_record/sql_source_spec.rb +401 -0
  169. data/spec/thinking_sphinx/configuration_spec.rb +264 -171
  170. data/spec/thinking_sphinx/deltas/default_delta_spec.rb +116 -0
  171. data/spec/thinking_sphinx/deltas_spec.rb +58 -0
  172. data/spec/thinking_sphinx/excerpter_spec.rb +40 -38
  173. data/spec/thinking_sphinx/facet_search_spec.rb +49 -151
  174. data/spec/thinking_sphinx/index_set_spec.rb +68 -0
  175. data/spec/thinking_sphinx/index_spec.rb +91 -155
  176. data/spec/thinking_sphinx/masks/pagination_mask_spec.rb +121 -0
  177. data/spec/thinking_sphinx/masks/scopes_mask_spec.rb +68 -0
  178. data/spec/thinking_sphinx/middlewares/active_record_translator_spec.rb +132 -0
  179. data/spec/thinking_sphinx/middlewares/geographer_spec.rb +89 -0
  180. data/spec/thinking_sphinx/middlewares/glazier_spec.rb +62 -0
  181. data/spec/thinking_sphinx/middlewares/inquirer_spec.rb +55 -0
  182. data/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +271 -0
  183. data/spec/thinking_sphinx/middlewares/stale_id_checker_spec.rb +47 -0
  184. data/spec/thinking_sphinx/middlewares/stale_id_filter_spec.rb +91 -0
  185. data/spec/thinking_sphinx/panes/attributes_pane_spec.rb +21 -0
  186. data/spec/thinking_sphinx/panes/distance_pane_spec.rb +41 -0
  187. data/spec/thinking_sphinx/panes/excerpts_pane_spec.rb +53 -0
  188. data/spec/thinking_sphinx/panes/weight_pane_spec.rb +20 -0
  189. data/spec/thinking_sphinx/rake_interface_spec.rb +147 -0
  190. data/spec/thinking_sphinx/real_time/attribute_spec.rb +62 -0
  191. data/spec/thinking_sphinx/real_time/callbacks/real_time_callbacks_spec.rb +76 -0
  192. data/spec/thinking_sphinx/real_time/field_spec.rb +54 -0
  193. data/spec/thinking_sphinx/real_time/index_spec.rb +154 -0
  194. data/spec/thinking_sphinx/real_time/interpreter_spec.rb +147 -0
  195. data/spec/thinking_sphinx/scopes_spec.rb +38 -0
  196. data/spec/thinking_sphinx/search/glaze_spec.rb +55 -0
  197. data/spec/thinking_sphinx/search/query_spec.rb +46 -0
  198. data/spec/thinking_sphinx/search_spec.rb +65 -1357
  199. data/spec/thinking_sphinx_spec.rb +19 -182
  200. data/thinking-sphinx.gemspec +33 -0
  201. metadata +318 -431
  202. data/features/abstract_inheritance.feature +0 -10
  203. data/features/alternate_primary_key.feature +0 -27
  204. data/features/attribute_transformation.feature +0 -22
  205. data/features/attribute_updates.feature +0 -79
  206. data/features/deleting_instances.feature +0 -70
  207. data/features/direct_attributes.feature +0 -11
  208. data/features/excerpts.feature +0 -21
  209. data/features/extensible_delta_indexing.feature +0 -9
  210. data/features/facets.feature +0 -88
  211. data/features/facets_across_model.feature +0 -29
  212. data/features/field_sorting.feature +0 -18
  213. data/features/handling_edits.feature +0 -97
  214. data/features/retry_stale_indexes.feature +0 -24
  215. data/features/searching_across_models.feature +0 -20
  216. data/features/searching_by_index.feature +0 -41
  217. data/features/searching_by_model.feature +0 -175
  218. data/features/searching_with_find_arguments.feature +0 -56
  219. data/features/sphinx_detection.feature +0 -25
  220. data/features/sphinx_scopes.feature +0 -68
  221. data/features/step_definitions/alpha_steps.rb +0 -16
  222. data/features/step_definitions/beta_steps.rb +0 -7
  223. data/features/step_definitions/common_steps.rb +0 -205
  224. data/features/step_definitions/extensible_delta_indexing_steps.rb +0 -7
  225. data/features/step_definitions/facet_steps.rb +0 -96
  226. data/features/step_definitions/find_arguments_steps.rb +0 -36
  227. data/features/step_definitions/gamma_steps.rb +0 -15
  228. data/features/step_definitions/scope_steps.rb +0 -19
  229. data/features/step_definitions/search_steps.rb +0 -94
  230. data/features/step_definitions/sphinx_steps.rb +0 -35
  231. data/features/sti_searching.feature +0 -19
  232. data/features/support/env.rb +0 -24
  233. data/features/support/lib/generic_delta_handler.rb +0 -8
  234. data/features/thinking_sphinx/database.example.yml +0 -3
  235. data/features/thinking_sphinx/db/.gitignore +0 -1
  236. data/features/thinking_sphinx/db/fixtures/alphas.rb +0 -8
  237. data/features/thinking_sphinx/db/fixtures/authors.rb +0 -1
  238. data/features/thinking_sphinx/db/fixtures/betas.rb +0 -11
  239. data/features/thinking_sphinx/db/fixtures/boxes.rb +0 -9
  240. data/features/thinking_sphinx/db/fixtures/categories.rb +0 -1
  241. data/features/thinking_sphinx/db/fixtures/cats.rb +0 -3
  242. data/features/thinking_sphinx/db/fixtures/comments.rb +0 -24
  243. data/features/thinking_sphinx/db/fixtures/developers.rb +0 -31
  244. data/features/thinking_sphinx/db/fixtures/dogs.rb +0 -3
  245. data/features/thinking_sphinx/db/fixtures/extensible_betas.rb +0 -10
  246. data/features/thinking_sphinx/db/fixtures/foxes.rb +0 -3
  247. data/features/thinking_sphinx/db/fixtures/gammas.rb +0 -10
  248. data/features/thinking_sphinx/db/fixtures/music.rb +0 -4
  249. data/features/thinking_sphinx/db/fixtures/people.rb +0 -1001
  250. data/features/thinking_sphinx/db/fixtures/post_keywords.txt +0 -1
  251. data/features/thinking_sphinx/db/fixtures/posts.rb +0 -10
  252. data/features/thinking_sphinx/db/fixtures/robots.rb +0 -8
  253. data/features/thinking_sphinx/db/fixtures/tags.rb +0 -27
  254. data/features/thinking_sphinx/db/migrations/create_alphas.rb +0 -8
  255. data/features/thinking_sphinx/db/migrations/create_animals.rb +0 -5
  256. data/features/thinking_sphinx/db/migrations/create_authors.rb +0 -3
  257. data/features/thinking_sphinx/db/migrations/create_authors_posts.rb +0 -6
  258. data/features/thinking_sphinx/db/migrations/create_betas.rb +0 -5
  259. data/features/thinking_sphinx/db/migrations/create_boxes.rb +0 -5
  260. data/features/thinking_sphinx/db/migrations/create_categories.rb +0 -3
  261. data/features/thinking_sphinx/db/migrations/create_comments.rb +0 -10
  262. data/features/thinking_sphinx/db/migrations/create_developers.rb +0 -7
  263. data/features/thinking_sphinx/db/migrations/create_extensible_betas.rb +0 -5
  264. data/features/thinking_sphinx/db/migrations/create_gammas.rb +0 -3
  265. data/features/thinking_sphinx/db/migrations/create_genres.rb +0 -3
  266. data/features/thinking_sphinx/db/migrations/create_music.rb +0 -6
  267. data/features/thinking_sphinx/db/migrations/create_people.rb +0 -13
  268. data/features/thinking_sphinx/db/migrations/create_posts.rb +0 -6
  269. data/features/thinking_sphinx/db/migrations/create_robots.rb +0 -4
  270. data/features/thinking_sphinx/db/migrations/create_taggings.rb +0 -5
  271. data/features/thinking_sphinx/db/migrations/create_tags.rb +0 -4
  272. data/features/thinking_sphinx/models/alpha.rb +0 -23
  273. data/features/thinking_sphinx/models/andrew.rb +0 -17
  274. data/features/thinking_sphinx/models/animal.rb +0 -5
  275. data/features/thinking_sphinx/models/author.rb +0 -3
  276. data/features/thinking_sphinx/models/beta.rb +0 -13
  277. data/features/thinking_sphinx/models/box.rb +0 -8
  278. data/features/thinking_sphinx/models/cat.rb +0 -3
  279. data/features/thinking_sphinx/models/category.rb +0 -4
  280. data/features/thinking_sphinx/models/comment.rb +0 -10
  281. data/features/thinking_sphinx/models/developer.rb +0 -21
  282. data/features/thinking_sphinx/models/dog.rb +0 -3
  283. data/features/thinking_sphinx/models/extensible_beta.rb +0 -9
  284. data/features/thinking_sphinx/models/fox.rb +0 -5
  285. data/features/thinking_sphinx/models/gamma.rb +0 -5
  286. data/features/thinking_sphinx/models/genre.rb +0 -3
  287. data/features/thinking_sphinx/models/medium.rb +0 -5
  288. data/features/thinking_sphinx/models/music.rb +0 -10
  289. data/features/thinking_sphinx/models/person.rb +0 -24
  290. data/features/thinking_sphinx/models/post.rb +0 -22
  291. data/features/thinking_sphinx/models/robot.rb +0 -12
  292. data/features/thinking_sphinx/models/tag.rb +0 -3
  293. data/lib/cucumber/thinking_sphinx/external_world.rb +0 -12
  294. data/lib/cucumber/thinking_sphinx/internal_world.rb +0 -137
  295. data/lib/cucumber/thinking_sphinx/sql_logger.rb +0 -28
  296. data/lib/thinking_sphinx/action_controller.rb +0 -31
  297. data/lib/thinking_sphinx/active_record/attribute_updates.rb +0 -54
  298. data/lib/thinking_sphinx/active_record/collection_proxy.rb +0 -47
  299. data/lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb +0 -27
  300. data/lib/thinking_sphinx/active_record/delta.rb +0 -67
  301. data/lib/thinking_sphinx/active_record/has_many_association.rb +0 -44
  302. data/lib/thinking_sphinx/active_record/has_many_association_with_scopes.rb +0 -21
  303. data/lib/thinking_sphinx/active_record/scopes.rb +0 -110
  304. data/lib/thinking_sphinx/adapters/abstract_adapter.rb +0 -94
  305. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +0 -62
  306. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +0 -188
  307. data/lib/thinking_sphinx/association.rb +0 -230
  308. data/lib/thinking_sphinx/attribute.rb +0 -405
  309. data/lib/thinking_sphinx/auto_version.rb +0 -40
  310. data/lib/thinking_sphinx/bundled_search.rb +0 -40
  311. data/lib/thinking_sphinx/class_facet.rb +0 -20
  312. data/lib/thinking_sphinx/connection.rb +0 -71
  313. data/lib/thinking_sphinx/context.rb +0 -81
  314. data/lib/thinking_sphinx/core/string.rb +0 -15
  315. data/lib/thinking_sphinx/deltas/delete_job.rb +0 -16
  316. data/lib/thinking_sphinx/deltas/index_job.rb +0 -17
  317. data/lib/thinking_sphinx/deploy/capistrano.rb +0 -99
  318. data/lib/thinking_sphinx/field.rb +0 -98
  319. data/lib/thinking_sphinx/index/builder.rb +0 -315
  320. data/lib/thinking_sphinx/index/faux_column.rb +0 -118
  321. data/lib/thinking_sphinx/join.rb +0 -37
  322. data/lib/thinking_sphinx/property.rb +0 -187
  323. data/lib/thinking_sphinx/search_methods.rb +0 -439
  324. data/lib/thinking_sphinx/sinatra.rb +0 -7
  325. data/lib/thinking_sphinx/source.rb +0 -194
  326. data/lib/thinking_sphinx/source/internal_properties.rb +0 -51
  327. data/lib/thinking_sphinx/source/sql.rb +0 -174
  328. data/spec/fixtures/data.sql +0 -32
  329. data/spec/fixtures/database.yml.default +0 -3
  330. data/spec/fixtures/models.rb +0 -164
  331. data/spec/fixtures/structure.sql +0 -146
  332. data/spec/sphinx_helper.rb +0 -60
  333. data/spec/support/rails.rb +0 -25
  334. data/spec/thinking_sphinx/active_record/delta_spec.rb +0 -123
  335. data/spec/thinking_sphinx/active_record/has_many_association_spec.rb +0 -173
  336. data/spec/thinking_sphinx/active_record/scopes_spec.rb +0 -177
  337. data/spec/thinking_sphinx/active_record_spec.rb +0 -573
  338. data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +0 -163
  339. data/spec/thinking_sphinx/association_spec.rb +0 -250
  340. data/spec/thinking_sphinx/attribute_spec.rb +0 -552
  341. data/spec/thinking_sphinx/auto_version_spec.rb +0 -103
  342. data/spec/thinking_sphinx/connection_spec.rb +0 -77
  343. data/spec/thinking_sphinx/context_spec.rb +0 -127
  344. data/spec/thinking_sphinx/core/array_spec.rb +0 -9
  345. data/spec/thinking_sphinx/core/string_spec.rb +0 -9
  346. data/spec/thinking_sphinx/facet_spec.rb +0 -359
  347. data/spec/thinking_sphinx/field_spec.rb +0 -127
  348. data/spec/thinking_sphinx/index/builder_spec.rb +0 -532
  349. data/spec/thinking_sphinx/index/faux_column_spec.rb +0 -36
  350. data/spec/thinking_sphinx/search_methods_spec.rb +0 -156
  351. data/spec/thinking_sphinx/source_spec.rb +0 -267
  352. data/spec/thinking_sphinx/test_spec.rb +0 -20
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle
3
+ .rbx
4
+ Gemfile.lock
5
+ *.sublime-*
6
+ pkg/*
7
+ spec/internal/config/test.sphinx.conf
8
+ spec/internal/db/sphinx
@@ -0,0 +1,13 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ before_install: gem update --system
5
+ before_script:
6
+ - "mysql -e 'create database thinking_sphinx;' > /dev/null"
7
+ - "psql -c 'create database thinking_sphinx;' -U postgres >/dev/null"
8
+ env:
9
+ - DATABASE=mysql2
10
+ - DATABASE=postgresql
11
+ gemfile:
12
+ - gemfiles/rails_3_1.gemfile
13
+ - gemfiles/rails_3_2.gemfile
@@ -0,0 +1,7 @@
1
+ appraise 'rails_3_1' do
2
+ gem 'rails', '~> 3.1.0'
3
+ end
4
+
5
+ appraise 'rails_3_2' do
6
+ gem 'rails', '~> 3.2.0'
7
+ end
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ gem 'combustion',
6
+ :git => 'git://github.com/pat/combustion.git',
7
+ :ref => '45f50e64c3'
8
+
9
+ gem 'pg', '~> 0.11.0', :platform => :ruby
10
+ gem 'activerecord-jdbcpostgresql-adapter', '~> 1.1.3', :platform => :jruby
data/HISTORY CHANGED
@@ -1,267 +1,2 @@
1
- 2.1.0 - May 7th 2013
2
- * 1.5.0 changes.
3
-
4
- 2.0.14 - January 2nd 2013
5
- * Fix model loading for Rails 3.2.9 when subdirectories exist (Kenn Ejima).
6
- * Use BasicObject instead of BlankSlate when running on 1.9 (Steve Purcell).
7
- * 1.4.14 changes.
8
-
9
- 2.0.13 - August 10th 2012
10
- * 1.4.13 changes.
11
-
12
- 2.0.12 - May 14th 2012
13
- * STI fix when generating WHERE clauses for sql_query.
14
- * 1.4.12 changes.
15
-
16
- 2.0.11 - January 2nd 2012
17
- * Call #all on search results to force population of results, matching ActiveRecord::Relation#all in essence. (Adrian Macneil).
18
- * 1.4.11 changes.
19
-
20
- 2.0.10 - November 4th 2011
21
- * 1.4.10 changes.
22
-
23
- 2.0.9 - October 10th 2011
24
- * 1.4.9 changes (fixed invalid gemspec).
25
-
26
- 2.0.8 - October 10th 2011
27
- * Actually looking at Rails engines paths for models (Eduardo Casanova).
28
- * Ensuring associations for acts-as-taggable-on are tweaked for Rails 3.1 (Anthony).
29
- * Bug fix for association collection proxies in Rails 3.1 (Pavel Forkert).
30
- * References all known Rails model paths - better for Rails 3 Engines.
31
- * Don't reload I18n anymore - the load order isn't an issue in Rails 3 or 3.1.
32
- * Fixing attribute source queries for Rails 3.1.
33
- * 1.4.8 changes
34
-
35
- 2.0.7 - August 29th 2011
36
- * Making sure lib directory is actually a part of the gem. Oops.
37
-
38
- 2.0.6 - August 28th 2011
39
- * Don't change superclass index definitions (otherwise sibling subclasses can end up with each others' index definitions).
40
- * Improved scope support (Andrew White).
41
- * Fixed association-filtered searches for Rails 3.1 (Andrew White).
42
- * Fixed polymorphic association support for Rails 3.1 (Jonathan Viney).
43
- * 1.4.7 changes.
44
-
45
- 2.0.5 - May 25th 2011
46
- * Railtie equivalent for Sinatra.
47
- * Rails 3.1 support (Florent Piteau).
48
- * 1.4.6 changes.
49
-
50
- 2.0.4 - May 12th 2011
51
- * Only determine Sphinx version when initializing Thinking Sphinx, instead of upon require.
52
- * Still execute logged blocks for searching even when logging isn't enabled.
53
- * 1.4.5 changes.
54
-
55
- 2.0.3 - April 3rd 2011
56
- * 1.4.4 changes.
57
-
58
- 2.0.2 - January 13th 2011
59
- * Improvement to loading the environment via Rake (Brenton Fletcher).
60
- * 1.4.2 changes.
61
- * 1.4.1 changes.
62
-
63
- 2.0.1 - November 19th 2011
64
- * Intermittent as_json bug fix.
65
- * Using Rails 3 logging system (Stephen Celis).
66
- * Fixes for Rails 3.0.2 (Ivan Ukhov).
67
-
68
- 2.0.0 - November 14th 2011
69
- * Handle has_many conditions defined as a hash (Artem Orlov).
70
- * Deprecation fixes for logging (Anton Sozontov).
71
- * Only load Thinking Sphinx if ActiveRecord is loaded (Matthew Higgins).
72
- * Rails 3 support.
73
- * 1.4.0 changes.
74
-
75
- 1.5.0 - May 7th 2013
76
- * Removed plugin support - Thinking Sphinx is now gem-only across all branches.
77
- * ThinkingSphinx::Version and the thinking_sphinx:version task have been removed - it's a gem, it has a version number.
78
- * Updating Riddle to 1.5.6 or newer.
79
- * Requires ActiveRecord ~> 2.1 (earlier versions were considered unsupported a few releases ago).
80
- * Allow custom Riddle controllers - useful for Flying Sphinx to take over management of Sphinx daemon/indexing actions.
81
- * Rejigged delta support to be generic, with local job classes that provide a clean, simple interface for third-party libraries.
82
- * Add hooks for anything that needs to happen before indexing (such as clearing out existing delta jobs).
83
- * Connection pool for all Sphinx client communication, with new connections built if there's any connection-related (as opposed to syntax) issues.
84
- * Multiple-field search conditions can be done with arrays of field names as keys in the :conditions hash (Alex Dowad).
85
- * Removed named capture in regular expressions to maintain MRI 1.8 support (Michael Wintrant).
86
- * Support new JDBC configuration style (Kyle Stevens).
87
-
88
- 1.4.14 - January 2nd 2013
89
- * Allow sql_query_pre values to come through from config/sphinx.yml (George Ogata).
90
- * ThinkingSphinx::Search#tap doesn't delegate through to the underlying array.
91
- * Use fire_delta? instance method in the model (if it exists) to decide whether indexing should happen.
92
- * Use full query in excerpts so double-stemming of terms is avoided (Jason Rust).
93
- * Fix thinking_sphinx:version rake task.
94
- * Directly compare non-string non-nil facet values for facet filters.
95
- * Don't bother checking with Sphinx whether documents exist when trying to update them. We're catching failures already (and Sphinx usually doesn't care anyway).
96
-
97
- 1.4.13 - August 10th 2012
98
- * Sphinx 2.0.5 support.
99
- * Hard retries for Sphinx exceptions (Andrew Hunter).
100
- * Add support for association-filtered faceting (Andrew White).
101
- * Cast PostgreSQL timestamps to their floored integers (instead of rounding up).
102
- * Don't add array_accum to PostgreSQL v80311 (8.3.?) or newer.
103
-
104
- 1.4.12 - May 14th 2012
105
- * Updating Riddle references to 1.5.2.
106
- * Can explicitly specify available types for STI tables instead of automatically discovering them with "SELECT DISTINCT type FROM <table>" (Cedric Maion).
107
- * Don't try to run rake tasks for Capistrano if there's no Rakefile - eg. on fresh deploys (Nathan Smith).
108
- * Populate search results before comparing with #==.
109
- * Can indicate whether Sphinx should use a socket for connections instead of TCP (Simon Hürlimann).
110
- * Can have just attribute values returned as search results using `:attributes_only => true` in a search call (Andrew Hunter).
111
- * Can specify additional local indices for the generated distributed index (usually one per model) (Andrew Hunter).
112
- * Supporting Sphinx 2.0.4 (Ilia Lobsanov).
113
- * Load MySQL SSL settings from database.yml (James Brooks).
114
- * Adding Sphinx 2.0.3 support (identical to 2.1.0).
115
- * Dropping Rails 1.2 and 2.0.x support.
116
- * Association keys now are the association stacks as arrays - more reliable in Rubinius.
117
- * Can now determine PostgreSQL versions with JRuby.
118
- * Many testing tweaks.
119
- * Allow for rank_expr option being passed through to Riddle.
120
-
121
- 1.4.11 - January 2nd 2012
122
- * Handle no results for total_pages and total_entries with defaults of 0.
123
- * No longer shuffle Sphinx addresses by default.
124
- * Fix coalescing of non-char values in PostgreSQL (Matthew Barnett).
125
- * Default database user for Sphinx configuration is now ENV['USER'], not root.
126
- * Alias offset to offset_value for Kaminari.
127
- * Sphinx 2.1.0-dev support.
128
-
129
- 1.4.10 - November 4th 2011
130
- * Updating Riddle references for impending 1.5.0 release of Riddle.
131
- * Handle out-of-date indexed_models references.
132
- * Fixing STI model handling during context index loading (Kenn Ejima).
133
-
134
- 1.4.9 - October 10th 2011
135
- * Fixing invalid gemspec.
136
-
137
- 1.4.8 - October 10th 2011
138
- * Adding smart default (id) for primary key column name.
139
- * Making error message when daemon fails to start a little more helpful (Tony Pitale).
140
- * Adding ThinkingSphinx::Search#last_page? for Kaminari (Pete Deffendol).
141
- * If ENV['NODETACH'] is set when calling ts:start, pass that flag through to Riddle to start Sphinx in the foreground (Aaron Gibralter).
142
- * Catch and report all errors when models are loaded (Martin Gordon).
143
- * Bringing in builder gem's BlankSlate for our Builder - better at keeping global Rake methods out of the way.
144
- * Use PostgreSQL's array_agg function if it exists, instead of array_accum (PG v8.4 or newer).
145
- * Shuffle multiple Sphinx addresses by default, but allow that to be turned off (Ngan Pham).
146
- * Fix string attributes when using Sphinx 2.0.1 and bin_path.
147
-
148
- 1.4.7 - August 28th 2011
149
- * Don't search for objects when updating attributes on every save - if the object isn't there, then the error will be caught anyway.
150
- * Extra flexibility for association attribute references (Andrew White).
151
- * Setting up test suite for Travis, and fixing tests across many rubies.
152
- * Removing test for filtering on wordcount attribute - seems Sphinx doesn't like that.
153
- * If many indices are searched on, only use the first for excerpts.
154
- * Allow MVA facets from SQL strings that are all integers to skip object translation.
155
- * Adding total_count method for better Kaminari support (Dan Pickett).
156
- * Switching from Jeweler to Bundler for gem management.
157
- * Cleaning up Context - re-using camelized class names.
158
- * Simplified auto-star regex for 1.9 - no need to set the unicode flag.
159
- * Don't update sphinx_internal_id attribute when updating a record's attributes.
160
- * Ignore empty arrays for :without_ids (Jason Rust).
161
- * Now catching Riddle::ResponseError when we aren't fussed about the responses from Sphinx.
162
- * Distinguishing between Ruby 1.8 and 1.9 for auto-star regex (Andrew White).
163
- * Don't re-index at the end of suspended_delta calls if requested.
164
- * Adding stop_timeout setting to configure how long ts:stop should wait while checking whether Sphinx has stopped (Justin Tanner).
165
- * Speed improvement for types_to_crcs (Josh Goebel).
166
- * Adding a touched_reindex_file option, for a file that will be touched after indices are rotated (Rémi Prévost).
167
- * Better support for the Mysql2 adapter (Andrew White).
168
- * More pagination methods - next_page? and first_page?.
169
- * Adding use_64_bit option to ensure all timestamp attributes are treated as 64 bit integers (Andrey Deryabin).
170
- * Simpler, less brittle support for all Sphinx settings via Riddle (Clemens Kofler).
171
- * Optimised start/stop behaviour in Capistrano recipe (Lars Weiler).
172
- * Catch and ignore timeout errors for low priority requests.
173
- * Don't double up on de-polymorphised associations for generated Sphinx source SQL queries.
174
-
175
- 1.4.6 - May 25th 2011
176
- * Require Riddle 1.3.3 or better.
177
- * Cast Sphinx document ids to 32bit integers to keep PostgreSQL happy when Sphinx is compiled for id64 support (Bruno Santschi).
178
- * Making sure suspended_delta always exists on indexed models, whether indices have been defined or not.
179
- * Workaround for ActsAsTaggableOn to ensure association joins work.
180
- * Use Sphinx string attributes instead of class_crc integers to determine which class each search result is from (Sphinx 2.x or newer).
181
- * String attribute support - and so, using this instead of str2ordinal for string sorting.
182
- * Support for fields with paired string attributes and wordcount attributes (Sphinx 1.10-beta or newer).
183
- * Support for file fields (Sphinx 1.10-beta or newer).
184
- * Wordcount attribute support (Sphinx 1.10-beta or newer).
185
- * Sinatra support is only used when Rails isn't loaded.
186
- * Sphinx 2.0.x (including 2.0.2-dev) support.
187
- * :without_any filtering option (the reverse of :with_all).
188
-
189
- 1.4.5 - May 12th 2011
190
- * Require Riddle 1.3.2 or better.
191
- * Improved 1.9.2 support
192
- * Don't hack Array - make ThinkingSphinx::Search a subclass of Array instead.
193
- * Distinguishing between suspended deltas and disabled deltas.
194
- * Removing most Thread references, opting for Mutexes for better multi-threading support.
195
- * Added support for client_key to allow for authenticated Sphinx communication.
196
- * Sphinx 2.0.1 support.
197
- * Don't try to translate nil values (Alex Chee).
198
- * Performance fix for facets (Clemens Kofler).
199
- * Use Sphinx 0.9.9 in Capistrano recipe (Konstantin Shabanov).
200
- * Sinatra support (Patrick Tulskie).
201
- * Offer sanitize_sql method within define_index blocks (Matt Todd).
202
- * Performance fix: caching primary_key_for_sphinx value.
203
-
204
- 1.4.4 - April 3 2011
205
- * Being consistent with === comparisons for Array monkeypatch.
206
- * Kaminari pagination support.
207
- * Ensure deltas are supported across multiple indices for a given model.
208
- * Use custom index names for excerpts calls if that's what exists (Javier Ramírez).
209
- * Allow for Sphinx versions compiled from source (Greg Weber).
210
- * Ensuring thread is being required to allow Mutexes to work.
211
- * Ensure primary_key_for_sphinx is inherited to subclasses (Robert Stern).
212
- * Don't complain if there's an error when checking for documents in a given index.
213
-
214
- 1.4.3 - January 29th 2011
215
- * Don't memoize the database adapter.
216
- * Allow queries to just return specific attributes via the :only option, instead of ActiveRecord objects (Hans Hasselberg).
217
- * Performance fix: Only add sphinx scopes to has_many associations if there are scopes in play (Kirill Maximov).
218
- * Fixing CRC32 function for PostgreSQL to handle UTF characters that use more than one byte.
219
-
220
- 1.4.2 - January 13th 2011
221
- * Ignore Sphinx errors when updating attributes (it's a low priority request).
222
- * Don't use the CRC32 function within the generated SQL queries for class types.
223
- * Direct facets to use a method to translate values using :value.
224
- * Ensure that if one sphinx_internal_id attribute is a bigint, they all are.
225
- * Ignore Sphinx errors when marking documents as deleted (it's a low priority request).
226
- * Don't select columns from polymorphic joins if they're not available.
227
- * Don't query Sphinx for a facet request if zero facets are requested.
228
- * Ensure we're only using local_options when it's available (Paul Schyska).
229
- * Don't presume the environment for Capistrano is production (Robert Glaser).
230
- * Allow for custom database adapters.
231
- * Fix for custom delta columns (Marcin Stecki).
232
-
233
- 1.4.1 - December 21st 2010
234
- * No longer looking for attributes in :conditions option when searching.
235
- * Copy and then modify sort arguments.
236
- * Allow the generation of Sphinx configuration objects without necessarily writing to the configuration file.
237
- * Allow Sphinx 1.10-beta versions that have been compiled with id64 support.
238
- * Raise Sphinx errors when searching - which can be ignored using the :ignore_errors option (Matt Todd).
239
- * Handle complex :include arguments, including hashes within arrays (Paco Guzmán).
240
- * Handle hashes passed through to :include when searching.
241
- * Can now require either 'thinking_sphinx' or 'thinking-sphinx'.
242
- * Excerpts are less fussy about inputs.
243
- * No longer hard-coding RSpec colour setting - that's up to the developer.
244
- * Require Riddle 1.2.0 or better.
245
- * Use searchd to stop Sphinx (via --stop or --stopwait arguments) (Matt Todd).
246
-
247
- 1.4.0 - November 14th 2010
248
- * No longer supporting attributes in :conditions option.
249
- * Case insensitive field sorting if :sortable is set to :insensitive.
250
- * Using Bundler for development
251
- * Can use make facet requests on existing searches and Sphinx scopes.
252
- * Don't star field markers in search queries.
253
- * Can use search_for_ids on Sphinx scopes.
254
- * Ensure the CRC32 function for PostgreSQL handles empty strings and NULLs.
255
- * Allow custom determination for database adapters.
256
- * :include search option now limits itself to the relevant classes when searching across more than one class.
257
- * Don't memoize primary_key_for_sphinx, which was causing trouble when objects are deleted or frozen.
258
- * Allow for excerpts options when searching (using :excerpt_options) (Lee Capps).
259
- * Wrap UTC in quotes when setting the timezone in PostgreSQL (Keith Pitt).
260
- * Don't colourize logs unless ActiveRecord allows for it.
261
- * Consistent contribution documentation (Sam Goldstein).
262
- * Allow the setting of Riddle's timeout value via sphinx.yml (Sam Goldstein).
263
- * 1.10-beta support.
264
- * Can set the riddle client for the search request using :client.
265
- * Fixing default sphinx scope support.
266
- * Make a reasonable attempt to check that Sphinx has stopped (Matt Todd).
267
- * Be more verbose if a model can't be loaded by Thinking Sphinx.
1
+ 2012-10-06: 3.0.0.pre
2
+ * First pre-release. Not quite feature complete, but the important stuff is certainly covered. See the README for more the finer details.
data/LICENCE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Pat Allan
1
+ Copyright (c) 2011 Pat Allan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,236 +1,204 @@
1
1
  h1. Thinking Sphinx
2
2
 
3
- Please note: this is the branch for Rails 3. At some point in the near future, it will be released as Thinking Sphinx 2.0. It does not work with versions of Rails before v3 - I'm not sure if that'll happen in the future, but was just too much hassle right now.
3
+ Welcome to Thinking Sphinx version 3 - a complete rewrite from past versions. Right now it is a work-in-progress, though it does include most of the more popular features from TS 2 and earlier. It's also currently built for Rails 3.1 or newer only.
4
4
 
5
- If you want to give this a spin, clone the repo, check out the rails3 branch, and run @rake build@ to generate the gem.
5
+ Still interested? Well, read on!
6
+
7
+ h2. Installation
8
+
9
+ There's only a pre-release gem available at this point - or you can use the git repository reference (the edge branch is what you're after). Also, you'll need to specify the Mysql2 gem as well (this is not an inbuilt dependency because JRuby, when supported, will need something different):
10
+
11
+ <pre><code>gem 'mysql2', '0.3.12b4'
12
+ gem 'thinking-sphinx', '3.0.0.pre'</code></pre>
6
13
 
7
14
  h2. Usage
8
15
 
9
- First, if you haven't done so already, check out the main "usage":http://ts.freelancing-gods.com/usage.html page. Once you've done that, the next place to look for information is the specific method docs - ThinkingSphinx::Search and ThinkingSphinx::Index::Builder in particular.
16
+ Indexes are no longer defined in models - they now live in `app/indices` (which you will need to create yourself). Each index should get its own file, and look something like this:
17
+
18
+ <pre><code># app/indices/article_index.rb
19
+ ThinkingSphinx::Index.define :article, :with => :active_record do
20
+ indexes title, content
21
+ indexes user.name, :as => :user
22
+ indexes user.articles.title, :as => :related_titles
23
+
24
+ has published
25
+ end</code></pre>
26
+
27
+ You'll notice the first argument is the model name downcased and as a symbol, and we are specifying the processor - @:active_record@. Everything inside the block is just like previous versions of Thinking Sphinx. Same goes for @config/thinking_sphinx.yml@ (formerly @config/sphinx.yml@).
28
+
29
+ Other changes:
30
+ * SphinxQL is now used instead of the old socket connections (hence the dependency on the @mysql2@ gem).
31
+ * You'll need to include @ThinkingSphinx::Scopes@ into your models if you want to use Sphinx scopes.
32
+ * The match mode is always extended - SphinxQL doesn't know any other way.
33
+ * ActiveRecord::Base.set_sphinx_primary_key is now an option in the index definition (alongside @:with@ in the above example): @:primary_key@ - and therefore is no longer inheritable between models.
34
+ * If you're explicitly setting a time attribute's type, instead of @:datetime@ it should now be @:timestamp@.
35
+ * Delta arguments are passed in as an option of the @define@ call, not within the block:
36
+
37
+ <pre><code>ThinkingSphinx::Index.define :article, :with => :active_record, :delta => true do
38
+ # ...
39
+ end</code></pre>
40
+
41
+ * Suspended deltas are no longer called from the model, but like so instead:
42
+
43
+ <pre><code>ThinkingSphinx::Deltas.suspend :article do
44
+ article.update_attributes(:title => 'pancakes')
45
+ end</code></pre>
46
+
47
+ * Excerpts through search results behaves the same way, provided you add ExcerptsPane into the mix (read the section below on search results, glazes and panes). Excerpt options (like @:before_match@, @:after_match@ and @:chunk_separator@) can be passed through when searching under the @:excerpts@ option:
48
+
49
+ <pre><code>ThinkingSphinx.search 'foo',
50
+ :excerpts => {:chunk_separator => ' -- '}</code></pre>
51
+
52
+ * When indexing models on classes that are using single-table inheritance (STI), make sure you have a database index on the @type@ column. Thinking Sphinx will need to determine which subclasses are available, and we can't rely on Rails having loaded all models at any given point, so it queries the database. If you don't want this to happen, set :skip_sti to true in your search call, and ensure that the :classes option holds all classes that could be returned.
53
+
54
+ <pre><code>ThinkingSphinx.search 'pancakes',
55
+ :skip_sti => true,
56
+ :classes => [User, AdminUser, SupportUser]</code></pre>
57
+
58
+ * The option @:rank_mode@ has now become @:ranker@ - and the options (as strings or symbols) are as follows: proximity_bm25, bm25, none, wordcount, proximity, matchany, and fieldmask.
59
+ * There are no explicit sorting modes - all sorting must be on attributes followed by ASC or DESC. For example: @:order => '@weight DESC, created_at ASC'@.
60
+ * If you specify just an attribute name as a symbol for the @:order@ option, it will be given the ascending direction by default. So, @:order => :created_at@ is equivalent to @:order => 'created_at ASC'@.
61
+ * If you want to use a calculated expression for sorting, you must specify the expression as a new attribute, then use that attribute in your @:order@ option. This is done using the @:select@ option to specify extra columns available in the underlying SphinxQL (_not_ ActiveRecord/SQL) query.
62
+
63
+ <pre><code>ThinkingSphinx.search(
64
+ :select => '@weight * 10 + document_boost as custom_weight',
65
+ :order => :custom_weight
66
+ )</code></pre>
67
+
68
+ * Support for latitude and longitude attributes named something other than 'lat' and 'lng' or 'latitude' and 'longitude' has been removed. May add it back in if requested, but would be surprised if it's a necessary feature.
69
+ * Set INDEX_ONLY to true in your shell for the index task to re-index without regenerating the configuration file.
70
+ * If you want to pass the old-style @:include@, @:joins@, @:select@ or @:order@ parameters through to the underlying ActiveRecord SQL queries for instantiating search results, they should go in a hash within the search option @:sql@:
71
+
72
+ <pre><code>Article.search :sql => {:include => :user}</code></pre>
73
+
74
+ * SphinxQL only supports grouping by single attributes - but these attributes may be generated on the fly within the select statement (see the @:select@ option above). A grouped search uses the @:group_by@ option, and you can pass in the attribute name as either a symbol or a string:
75
+
76
+ <pre><code>Article.search :group_by => :user_id</code></pre>
77
+
78
+ * If you want to change the order of which result appears for each group, that can be done via the @:order_group_by@ option - which behaves just like @:order@ does:
79
+
80
+ <pre><code>Article.search(
81
+ :group_by => :user_id,
82
+ :order_group_by => 'created_at DESC'
83
+ )</code></pre>
84
+
85
+ * The @each_with_group@, @each_with_count@ and @each_with_group_and_count@ enumerators are available when using the @:group_by@ option (but are otherwise not available to search objects). Please note the spelling - older versions of Thinking Sphinx allowed for groupby and group, this is no longer the case.
86
+ * @each_with_weight@ (again, note that it's weight, not weighting) is available, but not by default. Here's an example of how to have it part of the search object:
87
+
88
+ <pre><code>search = Article.search('pancakes', :select => '*, @weight')
89
+ search.masks << ThinkingSphinx::Masks::WeightEnumeratorMask
90
+
91
+ search.each_with_weight do |article, weight|
92
+ # ...
93
+ end</code></pre>
94
+
95
+ You'll also note here that I'm specifying the internal weight attribute. This is necessary for edge Sphinx post 2.0.5.
96
+
97
+ * Batched/Bulk searches are done pretty similarly as in the past - here's a code sample that'll only hit Sphinx once:
98
+
99
+ <pre><code>batch = ThinkingSphinx::BatchedSearch.new
100
+ batch.searches << Article.search('foo')
101
+ batch.searches << Article.search(:conditions => {:name => 'bar'})
102
+ batch.searches << Article.search_for_ids('baz')
103
+
104
+ # When you call batch#populate, the searches are all populated with a single
105
+ # Sphinx call.
106
+ batch.populate
107
+
108
+ batch.searches #=> [[foo results], [bar results], [baz results]]</code></pre>
109
+
110
+ * To search on specific indices, use the @:indices@ option, which expects an array of index names (including the @_core@ or @_delta@ suffixes).
111
+ * @:without_any@ has become @:without_all@ - and is implemented, but Sphinx doesn't yet support the required logic.
112
+ * If you're creating a multi-value attribute manually (using a SQL snippet), then in the definition pass in @:multi => true@, but @:type@ should be set as well, to one of the MVA types that Sphinx supports (@:integer@, @:timestamp@, or @:boolean@).
113
+ * Automatic updates of non-string attributes are still limited to those from columns on the model in question, and is disabled by default. To enable it, just set attribute_updates to true in your @config/sphinx.yml@.
114
+ * Search result helper methods are no longer injected into the actual result objects. Read the section below on search results, glazes and panes.
115
+ * If you're using string facets, make sure they're defined as fields, not strings. There is currently no support for multi-value string facets.
10
116
 
11
- Keep in mind that while Thinking Sphinx works for ActiveRecord with Merb, it doesn't yet support DataMapper (although that is planned).
117
+ h2. Search Middleware
118
+
119
+ This section needs information - go hunting in the source for the moment if you're keen on adding a layer around querying/result population process.
120
+
121
+ h2. Search results, Glazes and Panes
122
+
123
+ In versions of Thinking Sphinx prior to v3, each search result object had many methods inserted into it - for direct access to the weight, distance, sphinx attributes and excerpts. This is no longer the case, but there is a more modular approach available.
124
+
125
+ Search results may now have a glaze object placed around them, which can then delegate methods to any number of panes the glaze has available. By default, there are no panes added (and thus, no glazing), but this can be modified:
126
+
127
+ <pre><code># For every search
128
+ ThinkingSphinx::Configuration::Defaults::PANES << ThinkingSphinx::Panes::WeightPane
129
+
130
+ # Or for specific searches:
131
+ search = ThinkingSphinx.search('pancakes')
132
+ search.context[:panes] << ThinkingSphinx::Panes::WeightPane</code></pre>
133
+
134
+ The available panes are as follows:
135
+
136
+ * @WeightPane@ (methods: @weight@)
137
+ * @DistancePane@ (methods: @distance@, @geodist@)
138
+ * @AttributesPane@ (methods: @sphinx_attributes@)
139
+ * @ExcerptsPane@ (methods: @excerpts@)
140
+
141
+ All panes namespaced to @ThinkingSphinx::Panes@, and the @DistancePane@ is automatically added when you provide latitude/longitude values via the @:geo@ option.
142
+
143
+ If you wish to add your own panes, go ahead. The only requirement is that the initializer must accept three arguments: the search context, the underlying search result object, and a hash of the raw values from Sphinx.
144
+
145
+ h2. Limitations
146
+
147
+ Basic indexing and searching should be fine. There's currently only limited basic delta support. Some settings haven't yet been brought across. Many of the smaller features don't yet exist either. Some may actually not return... we'll see.
148
+
149
+ Lists of what still needs to be implemented, in no particular order but in groups of vague importance:
150
+
151
+ Required for Release Candidate:
152
+
153
+ * Query and Ranged Query sources for Attributes and Fields
154
+ * Using :though association shortcuts in index definitions
155
+ * Overwritable toggle_delta? method on model
156
+ * Query times for searches
157
+ * Namespaced models support
158
+ * Delayed Deltas
159
+ * Infixing and Prefixing of specific fields
160
+ * Default Sphinx scopes
161
+ * sanitise_sql method in index definitions
162
+ * Multiple sources for an index
163
+ * JRuby support
164
+ * Sinatra support
165
+ * Wordcount fields and attributes
166
+
167
+ May or may not be added:
168
+
169
+ * Datetime Deltas
170
+ * Bitmask weighting helper
171
+ * Timezone support (for databases not using UTC)
172
+ * Abstract Inheritance support (maybe - not sure this is something many of people want).
173
+ * Capistrano Tasks
174
+ * Facet support for arrays of strings.
175
+
176
+ h3. Sphinx Versions
177
+
178
+ TS 3 is built for Sphinx 2.x only. You cannot use 1.10-beta, 0.9.9 or anything earlier than that.
179
+
180
+ h3. Rails Versions
181
+
182
+ Currently TS 3 is built to support Rails/ActiveRecord 3.1 or newer. Sinatra is not yet supported, but it will be.
183
+
184
+ TS 3 does not support Rails 3.0, Rails 2.x or earlier, or Merb - please refer to the TS 1.x and 2.x releases in those situations.
185
+
186
+ h3. Ruby Versions
187
+
188
+ Built on MRI 1.9.3 and tested against MRI 1.9.2 as well. No plans to support MRI 1.8, but would like to support Rubinius and JRuby (the one catch with the latter is the different MySQL interfaces).
189
+
190
+ h3. Database Versions
191
+
192
+ MySQL 5.x and Postgres 8.4 or better are supported.
12
193
 
13
194
  h2. Contributing
14
195
 
15
- Fork on GitHub and after you've committed tested patches, send a pull request.
16
-
17
- To quickly see if your system is ready to run the thinking sphinx specs, run the contribute.rb script found in the project root directory. Use the following instructions to install any missing requirements.
18
-
19
- To get the spec suite running, you will need to install the ginger gem:
20
-
21
- <pre><code>sudo gem install ginger --source http://gemcutter.org</code></pre>
22
-
23
- 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.
24
-
25
- <pre>
26
- sudo gem install bluecloth cucumber yard jeweler rspec
27
- </pre>
28
-
29
- Then set up your database:
30
-
31
- <pre>
32
- cp spec/fixtures/database.yml.default spec/fixtures/database.yml &&
33
- mysqladmin -u root create thinking_sphinx
34
- </pre>
35
-
36
- This last step can be done automatically by the contribute.rb script if all dependencies are met.
37
-
38
- Make sure you don't have another Sphinx daemon (searchd) running. If you do, quit it with "rake ts:stop"
39
- in the app root.
40
-
41
- You should now have a passing test suite from which to build your patch on.
42
-
43
- <pre>
44
- rake spec
45
- </pre>
46
-
47
- If you get the message "Failed to start searchd daemon", run the spec with sudo:
48
-
49
- <pre>
50
- sudo rake spec
51
- </pre>
52
-
53
- If you quit the spec suite before it's completed, you may be left with data in the test
54
- database, causing the next run to have failures. Let that run complete and then try again.
55
-
56
- h2. Contributors
57
-
58
- Since I first released this library, there's been quite a few people who have submitted patches, to my immense gratitude. Others have suggested syntax changes and general improvements. So my thanks to the following people:
59
-
60
- * Joost Hietbrink
61
- * Jonathan Conway
62
- * Gregory Mirzayantz
63
- * Tung Nguyen
64
- * Sean Cribbs
65
- * Benoit Caccinolo
66
- * John Barton
67
- * Oliver Beddows
68
- * Arthur Zapparoli
69
- * Dusty Doris
70
- * Marcus Crafter
71
- * Patrick Lenz
72
- * Björn Andreasson
73
- * James Healy
74
- * Jae-Jun Hwang
75
- * Xavier Shay
76
- * Jason Rust
77
- * Gopal Patel
78
- * Chris Heald
79
- * Peter Vandenberk
80
- * Josh French
81
- * Andrew Bennett
82
- * Jordan Fowler
83
- * Seth Walker
84
- * Joe Noon
85
- * Wolfgang Postler
86
- * Rick Olson
87
- * Killian Murphy
88
- * Morten Primdahl
89
- * Ryan Bates
90
- * David Eisinger
91
- * Shay Arnett
92
- * Minh Tran
93
- * Jeremy Durham
94
- * Piotr Sarnacki
95
- * Matt Johnson
96
- * Nicolas Blanco
97
- * Max Lapshin
98
- * Josh Natanson
99
- * Philip Hallstrom
100
- * Christian Rishøj
101
- * Mike Flester
102
- * Jim Remsik
103
- * Kennon Ballou
104
- * Henrik Nyh
105
- * Emil Tin
106
- * Doug Cole
107
- * Ed Hickey
108
- * Evan Weaver
109
- * Thibaut Barrere
110
- * Kristopher Chambers
111
- * Dmitrij Smalko
112
- * Aleksey Yeschenko
113
- * Lachie Cox
114
- * Lourens Naude
115
- * Tom Davies
116
- * Dan Pickett
117
- * Alex Caudill
118
- * Jim Benton
119
- * John Aughey
120
- * Keith Pitty
121
- * Jeff Talbot
122
- * Dana Contreras
123
- * Menno van der Sman
124
- * Bill Harding
125
- * Isaac Feliu
126
- * Andrei Bocan
127
- * László Bácsi
128
- * Peter Wagenet
129
- * Martin Emde
130
- * David Wennergren
131
- * Mark Lane
132
- * Eric Lindvall
133
- * Lawrence Pit
134
- * Mike Bailey
135
- * Bill Leeper
136
- * Michael Reinsch
137
- * Anderson Dias
138
- * Jerome Riga
139
- * Tien Dung
140
- * Johannes Kaefer
141
- * Paul Campbell
142
- * Matthew Beale
143
- * Tom Simnett
144
- * Erik Ostrom
145
- * Ole Riesenberg
146
- * Josh Kalderimis
147
- * J.D. Hollis
148
- * Jeffrey Chupp
149
- * Rob Anderton
150
- * Zach Inglis
151
- * Ward Bekker
152
- * Brian Terlson
153
- * Christian Aust
154
- * Martin Sarasale
155
- * Édouard Brière
156
- * Steve Madsen
157
- * Justin DeWind
158
- * Chris Z
159
- * Chris Roos
160
- * Andrew Assarattanakul
161
- * Jonas von Andrian
162
- * Dimitri Krassovski
163
- * Sergey Kojin
164
- * Brad Sumersford
165
- * Amir Yalon
166
- * Edgars Beigarts
167
- * Ivan Ukhov
168
- * Tomáš Pospíšek
169
- * Jeffrey Hardy
170
- * David Heinemeier Hansson
171
- * Jimmy Hsu
172
- * Bruno Michel
173
- * Joren De Groof
174
- * Jan De Poorter
175
- * Tom Stuart
176
- * James Brooks
177
- * Andrew Coldham
178
- * Mark Dodwell
179
- * Frédéric Malamitsas
180
- * Jon Gubman
181
- * Michael Schuerig
182
- * Ben Hutton
183
- * Alfonso Jiménez
184
- * Szymon Nowak
185
- * Matthew Higgins
186
- * Anton Sozontov
187
- * Keith Pitt
188
- * Lee Capps
189
- * Sam Goldstein
190
- * Artem Orlov
191
- * Matt Todd
192
- * Ivan Ukhov
193
- * Stephen Celis
194
- * Paco Guzmán
195
- * Marcin Stecki
196
- * Robert Glaser
197
- * Brenton Fletcher
198
- * Paul Schyska
199
- * Kirill Maximov
200
- * Hans Hasselberg
201
- * Robert Stern
202
- * George Anderson
203
- * Greg Weber
204
- * Javier Ramírez
205
- * Patrick Tulskie
206
- * Konstantin Shabanov
207
- * Clemens Kofler
208
- * Ryan Mohr
209
- * Alex Chee
210
- * Florent Piteau
211
- * Bruno Santschi
212
- * Lars Weiler
213
- * Andrey Deryabin
214
- * Andrew White
215
- * Rémi Prévost
216
- * Justin Tanner
217
- * Josh Goebel
218
- * Jonathan Viney
219
- * Ngan Pham
220
- * Martin Gordon
221
- * Aaron Gibralter
222
- * Pavel Forkert
223
- * Anthony Byram
224
- * Pete Deffendol
225
- * Eduardo Casanova
226
- * Tony Pitale
227
- * Kenn Ejima
228
- * Matthew Barnett
229
- * Adrian Macneil
230
- * Ilia Lobsanov
231
- * Andrew Hunter
232
- * Simon Hürlimann
233
- * Nathan Smith
234
- * Cedric Maion
235
- * Steve Purcell
236
- * George Ogata
196
+ 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.
197
+
198
+ 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!
199
+
200
+ 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.
201
+
202
+ h2. Licence
203
+
204
+ Copyright (c) 2007-2012, Thinking Sphinx is developed and maintained by Pat Allan, and is released under the open MIT Licence. Many thanks to "all who have contributed patches":https://github.com/freelancing-god/thinking-sphinx/contributors.