sunspot 2.0.0.pre.120720 → 2.0.0.pre.120924

Sign up to get free protection for your applications and to get access to all the features.
Files changed (299) hide show
  1. data/.gitignore +9 -11
  2. data/.travis.yml +35 -0
  3. data/README.md +863 -0
  4. data/Rakefile +32 -8
  5. data/ci/travis.sh +67 -0
  6. data/sunspot/.gitignore +13 -0
  7. data/{Gemfile → sunspot/Gemfile} +0 -0
  8. data/{History.txt → sunspot/History.txt} +0 -0
  9. data/{LICENSE → sunspot/LICENSE} +0 -0
  10. data/sunspot/Rakefile +13 -0
  11. data/{TODO → sunspot/TODO} +0 -0
  12. data/{lib → sunspot/lib}/light_config.rb +0 -0
  13. data/{lib → sunspot/lib}/sunspot/adapters.rb +85 -5
  14. data/{lib → sunspot/lib}/sunspot/batcher.rb +0 -0
  15. data/{lib → sunspot/lib}/sunspot/class_set.rb +0 -0
  16. data/{lib → sunspot/lib}/sunspot/composite_setup.rb +0 -0
  17. data/{lib → sunspot/lib}/sunspot/configuration.rb +0 -0
  18. data/{lib → sunspot/lib}/sunspot/data_extractor.rb +0 -0
  19. data/{lib → sunspot/lib}/sunspot/dsl/adjustable.rb +0 -0
  20. data/{lib → sunspot/lib}/sunspot/dsl/field_group.rb +2 -2
  21. data/{lib → sunspot/lib}/sunspot/dsl/field_query.rb +1 -1
  22. data/{lib → sunspot/lib}/sunspot/dsl/fields.rb +0 -0
  23. data/{lib → sunspot/lib}/sunspot/dsl/fulltext.rb +0 -0
  24. data/{lib → sunspot/lib}/sunspot/dsl/function.rb +0 -0
  25. data/{lib → sunspot/lib}/sunspot/dsl/functional.rb +0 -0
  26. data/{lib → sunspot/lib}/sunspot/dsl/more_like_this_query.rb +0 -0
  27. data/{lib → sunspot/lib}/sunspot/dsl/paginatable.rb +0 -0
  28. data/{lib → sunspot/lib}/sunspot/dsl/query_facet.rb +0 -0
  29. data/{lib → sunspot/lib}/sunspot/dsl/restriction.rb +0 -0
  30. data/{lib → sunspot/lib}/sunspot/dsl/restriction_with_near.rb +0 -0
  31. data/{lib → sunspot/lib}/sunspot/dsl/scope.rb +8 -11
  32. data/{lib → sunspot/lib}/sunspot/dsl/search.rb +0 -0
  33. data/{lib → sunspot/lib}/sunspot/dsl/standard_query.rb +3 -4
  34. data/{lib → sunspot/lib}/sunspot/dsl.rb +0 -0
  35. data/{lib → sunspot/lib}/sunspot/field.rb +0 -0
  36. data/{lib → sunspot/lib}/sunspot/field_factory.rb +0 -0
  37. data/{lib → sunspot/lib}/sunspot/indexer.rb +0 -0
  38. data/{lib → sunspot/lib}/sunspot/query/abstract_field_facet.rb +1 -1
  39. data/{lib → sunspot/lib}/sunspot/query/bbox.rb +0 -0
  40. data/{lib → sunspot/lib}/sunspot/query/boost_query.rb +0 -0
  41. data/{lib → sunspot/lib}/sunspot/query/common_query.rb +0 -0
  42. data/{lib → sunspot/lib}/sunspot/query/composite_fulltext.rb +0 -0
  43. data/{lib → sunspot/lib}/sunspot/query/connective.rb +0 -0
  44. data/{lib → sunspot/lib}/sunspot/query/date_field_facet.rb +0 -0
  45. data/{lib → sunspot/lib}/sunspot/query/dismax.rb +0 -0
  46. data/{lib → sunspot/lib}/sunspot/query/field_facet.rb +0 -0
  47. data/{lib → sunspot/lib}/sunspot/query/field_group.rb +0 -0
  48. data/{lib → sunspot/lib}/sunspot/query/filter.rb +0 -0
  49. data/{lib → sunspot/lib}/sunspot/query/function_query.rb +0 -0
  50. data/{lib → sunspot/lib}/sunspot/query/geo.rb +0 -0
  51. data/{lib → sunspot/lib}/sunspot/query/geofilt.rb +0 -0
  52. data/{lib → sunspot/lib}/sunspot/query/highlighting.rb +0 -0
  53. data/{lib → sunspot/lib}/sunspot/query/more_like_this.rb +0 -0
  54. data/{lib → sunspot/lib}/sunspot/query/more_like_this_query.rb +0 -0
  55. data/{lib → sunspot/lib}/sunspot/query/pagination.rb +0 -0
  56. data/{lib → sunspot/lib}/sunspot/query/query_facet.rb +0 -0
  57. data/{lib → sunspot/lib}/sunspot/query/range_facet.rb +1 -0
  58. data/{lib → sunspot/lib}/sunspot/query/restriction.rb +12 -0
  59. data/{lib → sunspot/lib}/sunspot/query/scope.rb +0 -0
  60. data/{lib → sunspot/lib}/sunspot/query/sort.rb +0 -0
  61. data/{lib → sunspot/lib}/sunspot/query/sort_composite.rb +0 -0
  62. data/{lib → sunspot/lib}/sunspot/query/standard_query.rb +0 -0
  63. data/{lib → sunspot/lib}/sunspot/query/text_field_boost.rb +0 -0
  64. data/{lib → sunspot/lib}/sunspot/query.rb +0 -0
  65. data/{lib → sunspot/lib}/sunspot/schema.rb +0 -0
  66. data/{lib → sunspot/lib}/sunspot/search/abstract_search.rb +2 -2
  67. data/{lib → sunspot/lib}/sunspot/search/date_facet.rb +0 -0
  68. data/{lib → sunspot/lib}/sunspot/search/facet_row.rb +0 -0
  69. data/{lib → sunspot/lib}/sunspot/search/field_facet.rb +0 -0
  70. data/sunspot/lib/sunspot/search/field_group.rb +70 -0
  71. data/{lib → sunspot/lib}/sunspot/search/group.rb +0 -0
  72. data/{lib → sunspot/lib}/sunspot/search/highlight.rb +0 -0
  73. data/{lib → sunspot/lib}/sunspot/search/hit.rb +0 -0
  74. data/{lib → sunspot/lib}/sunspot/search/hit_enumerable.rb +5 -9
  75. data/{lib → sunspot/lib}/sunspot/search/more_like_this_search.rb +0 -0
  76. data/{lib → sunspot/lib}/sunspot/search/paginated_collection.rb +0 -0
  77. data/{lib → sunspot/lib}/sunspot/search/query_facet.rb +0 -0
  78. data/{lib → sunspot/lib}/sunspot/search/range_facet.rb +0 -0
  79. data/{lib → sunspot/lib}/sunspot/search/standard_search.rb +0 -0
  80. data/{lib → sunspot/lib}/sunspot/search.rb +0 -0
  81. data/{lib → sunspot/lib}/sunspot/session.rb +0 -0
  82. data/{lib → sunspot/lib}/sunspot/session_proxy/abstract_session_proxy.rb +0 -0
  83. data/{lib → sunspot/lib}/sunspot/session_proxy/class_sharding_session_proxy.rb +0 -0
  84. data/{lib → sunspot/lib}/sunspot/session_proxy/id_sharding_session_proxy.rb +0 -0
  85. data/{lib → sunspot/lib}/sunspot/session_proxy/master_slave_session_proxy.rb +0 -0
  86. data/{lib → sunspot/lib}/sunspot/session_proxy/retry_5xx_session_proxy.rb +0 -0
  87. data/{lib → sunspot/lib}/sunspot/session_proxy/sharding_session_proxy.rb +0 -0
  88. data/{lib → sunspot/lib}/sunspot/session_proxy/silent_fail_session_proxy.rb +0 -0
  89. data/{lib → sunspot/lib}/sunspot/session_proxy/thread_local_session_proxy.rb +0 -0
  90. data/{lib → sunspot/lib}/sunspot/session_proxy.rb +0 -0
  91. data/{lib → sunspot/lib}/sunspot/setup.rb +0 -0
  92. data/{lib → sunspot/lib}/sunspot/text_field_setup.rb +0 -0
  93. data/{lib → sunspot/lib}/sunspot/type.rb +0 -0
  94. data/{lib → sunspot/lib}/sunspot/util.rb +0 -0
  95. data/sunspot/lib/sunspot/version.rb +3 -0
  96. data/{lib → sunspot/lib}/sunspot.rb +0 -0
  97. data/{log → sunspot/log}/.gitignore +0 -0
  98. data/{pkg → sunspot/pkg}/.gitignore +0 -0
  99. data/{script → sunspot/script}/console +0 -0
  100. data/sunspot/spec/api/adapters_spec.rb +68 -0
  101. data/{spec → sunspot/spec}/api/batcher_spec.rb +0 -0
  102. data/{spec → sunspot/spec}/api/binding_spec.rb +0 -0
  103. data/{spec → sunspot/spec}/api/class_set_spec.rb +0 -0
  104. data/{spec → sunspot/spec}/api/hit_enumerable_spec.rb +0 -0
  105. data/{spec → sunspot/spec}/api/indexer/attributes_spec.rb +0 -0
  106. data/{spec → sunspot/spec}/api/indexer/batch_spec.rb +0 -0
  107. data/{spec → sunspot/spec}/api/indexer/dynamic_fields_spec.rb +0 -0
  108. data/{spec → sunspot/spec}/api/indexer/fixed_fields_spec.rb +0 -0
  109. data/{spec → sunspot/spec}/api/indexer/fulltext_spec.rb +0 -0
  110. data/{spec → sunspot/spec}/api/indexer/removal_spec.rb +0 -0
  111. data/{spec → sunspot/spec}/api/indexer/spec_helper.rb +0 -0
  112. data/{spec → sunspot/spec}/api/indexer_spec.rb +0 -0
  113. data/{spec → sunspot/spec}/api/query/advanced_manipulation_examples.rb +0 -0
  114. data/{spec → sunspot/spec}/api/query/connectives_examples.rb +12 -0
  115. data/{spec → sunspot/spec}/api/query/dsl_spec.rb +0 -0
  116. data/{spec → sunspot/spec}/api/query/dynamic_fields_examples.rb +0 -0
  117. data/{spec → sunspot/spec}/api/query/faceting_examples.rb +8 -8
  118. data/{spec → sunspot/spec}/api/query/fulltext_examples.rb +0 -0
  119. data/{spec → sunspot/spec}/api/query/function_spec.rb +0 -0
  120. data/{spec → sunspot/spec}/api/query/geo_examples.rb +0 -0
  121. data/{spec → sunspot/spec}/api/query/group_spec.rb +0 -0
  122. data/{spec → sunspot/spec}/api/query/highlighting_examples.rb +0 -0
  123. data/{spec → sunspot/spec}/api/query/more_like_this_spec.rb +0 -0
  124. data/{spec → sunspot/spec}/api/query/ordering_pagination_examples.rb +0 -0
  125. data/{spec → sunspot/spec}/api/query/scope_examples.rb +0 -0
  126. data/{spec → sunspot/spec}/api/query/spatial_examples.rb +0 -0
  127. data/{spec → sunspot/spec}/api/query/spec_helper.rb +0 -0
  128. data/{spec → sunspot/spec}/api/query/standard_spec.rb +0 -0
  129. data/{spec → sunspot/spec}/api/query/text_field_scoping_examples.rb +0 -0
  130. data/{spec → sunspot/spec}/api/query/types_spec.rb +0 -0
  131. data/{spec → sunspot/spec}/api/search/dynamic_fields_spec.rb +0 -0
  132. data/{spec → sunspot/spec}/api/search/faceting_spec.rb +0 -0
  133. data/{spec → sunspot/spec}/api/search/highlighting_spec.rb +0 -0
  134. data/{spec → sunspot/spec}/api/search/hits_spec.rb +16 -0
  135. data/{spec → sunspot/spec}/api/search/paginated_collection_spec.rb +0 -0
  136. data/{spec → sunspot/spec}/api/search/results_spec.rb +0 -0
  137. data/{spec → sunspot/spec}/api/search/search_spec.rb +0 -0
  138. data/{spec → sunspot/spec}/api/search/spec_helper.rb +0 -0
  139. data/{spec → sunspot/spec}/api/session_proxy/class_sharding_session_proxy_spec.rb +0 -0
  140. data/{spec → sunspot/spec}/api/session_proxy/id_sharding_session_proxy_spec.rb +0 -0
  141. data/{spec → sunspot/spec}/api/session_proxy/master_slave_session_proxy_spec.rb +0 -0
  142. data/{spec → sunspot/spec}/api/session_proxy/retry_5xx_session_proxy_spec.rb +5 -0
  143. data/{spec → sunspot/spec}/api/session_proxy/sharding_session_proxy_spec.rb +0 -0
  144. data/{spec → sunspot/spec}/api/session_proxy/silent_fail_session_proxy_spec.rb +0 -0
  145. data/{spec → sunspot/spec}/api/session_proxy/spec_helper.rb +0 -0
  146. data/{spec → sunspot/spec}/api/session_proxy/thread_local_session_proxy_spec.rb +0 -0
  147. data/{spec → sunspot/spec}/api/session_spec.rb +0 -0
  148. data/{spec → sunspot/spec}/api/spec_helper.rb +0 -0
  149. data/{spec → sunspot/spec}/api/sunspot_spec.rb +2 -2
  150. data/{spec → sunspot/spec}/ext.rb +0 -0
  151. data/{spec → sunspot/spec}/helpers/indexer_helper.rb +0 -0
  152. data/{spec → sunspot/spec}/helpers/integration_helper.rb +0 -0
  153. data/{spec → sunspot/spec}/helpers/mock_session_helper.rb +0 -0
  154. data/{spec → sunspot/spec}/helpers/query_helper.rb +0 -0
  155. data/{spec → sunspot/spec}/helpers/search_helper.rb +0 -0
  156. data/{spec → sunspot/spec}/integration/dynamic_fields_spec.rb +0 -0
  157. data/{spec → sunspot/spec}/integration/faceting_spec.rb +26 -0
  158. data/{spec → sunspot/spec}/integration/field_grouping_spec.rb +0 -0
  159. data/{spec → sunspot/spec}/integration/geospatial_spec.rb +11 -0
  160. data/{spec → sunspot/spec}/integration/highlighting_spec.rb +0 -0
  161. data/{spec → sunspot/spec}/integration/indexing_spec.rb +0 -0
  162. data/{spec → sunspot/spec}/integration/keyword_search_spec.rb +0 -0
  163. data/{spec → sunspot/spec}/integration/local_search_spec.rb +0 -0
  164. data/{spec → sunspot/spec}/integration/more_like_this_spec.rb +0 -0
  165. data/{spec → sunspot/spec}/integration/scoped_search_spec.rb +0 -0
  166. data/{spec → sunspot/spec}/integration/stored_fields_spec.rb +0 -0
  167. data/{spec → sunspot/spec}/integration/test_pagination.rb +0 -0
  168. data/{spec → sunspot/spec}/integration/unicode_spec.rb +0 -0
  169. data/{spec → sunspot/spec}/mocks/adapters.rb +1 -0
  170. data/{spec → sunspot/spec}/mocks/blog.rb +0 -0
  171. data/{spec → sunspot/spec}/mocks/comment.rb +0 -0
  172. data/{spec → sunspot/spec}/mocks/connection.rb +0 -0
  173. data/{spec → sunspot/spec}/mocks/mock_adapter.rb +0 -0
  174. data/{spec → sunspot/spec}/mocks/mock_class_sharding_session_proxy.rb +0 -0
  175. data/{spec → sunspot/spec}/mocks/mock_record.rb +0 -0
  176. data/{spec → sunspot/spec}/mocks/mock_sharding_session_proxy.rb +0 -0
  177. data/{spec → sunspot/spec}/mocks/photo.rb +0 -0
  178. data/{spec → sunspot/spec}/mocks/post.rb +0 -0
  179. data/{spec → sunspot/spec}/mocks/super_class.rb +0 -0
  180. data/{spec → sunspot/spec}/mocks/user.rb +0 -0
  181. data/{spec → sunspot/spec}/spec_helper.rb +0 -0
  182. data/{sunspot.gemspec → sunspot/sunspot.gemspec} +0 -0
  183. data/{tasks → sunspot/tasks}/rdoc.rake +0 -0
  184. data/{tasks → sunspot/tasks}/schema.rake +0 -0
  185. data/{tasks → sunspot/tasks}/todo.rake +0 -0
  186. data/sunspot_rails/.gitignore +7 -0
  187. data/sunspot_rails/.rspec +1 -0
  188. data/sunspot_rails/History.txt +74 -0
  189. data/sunspot_rails/LICENSE +18 -0
  190. data/sunspot_rails/MIT-LICENSE +20 -0
  191. data/sunspot_rails/README.rdoc +265 -0
  192. data/sunspot_rails/Rakefile +17 -0
  193. data/sunspot_rails/TODO +8 -0
  194. data/sunspot_rails/dev_tasks/rdoc.rake +24 -0
  195. data/sunspot_rails/dev_tasks/release.rake +4 -0
  196. data/sunspot_rails/dev_tasks/spec.rake +107 -0
  197. data/sunspot_rails/dev_tasks/todo.rake +4 -0
  198. data/sunspot_rails/gemfiles/rails-2.3.14 +12 -0
  199. data/sunspot_rails/gemfiles/rails-3.0.15 +12 -0
  200. data/sunspot_rails/gemfiles/rails-3.1.6 +12 -0
  201. data/sunspot_rails/gemfiles/rails-3.2.6 +12 -0
  202. data/sunspot_rails/generators/sunspot/sunspot_generator.rb +9 -0
  203. data/sunspot_rails/generators/sunspot/templates/sunspot.yml +20 -0
  204. data/sunspot_rails/install.rb +1 -0
  205. data/sunspot_rails/lib/generators/sunspot_rails/install/install_generator.rb +13 -0
  206. data/sunspot_rails/lib/generators/sunspot_rails/install/templates/config/sunspot.yml +19 -0
  207. data/sunspot_rails/lib/generators/sunspot_rails.rb +9 -0
  208. data/sunspot_rails/lib/sunspot/rails/adapters.rb +88 -0
  209. data/sunspot_rails/lib/sunspot/rails/configuration.rb +352 -0
  210. data/sunspot_rails/lib/sunspot/rails/init.rb +5 -0
  211. data/sunspot_rails/lib/sunspot/rails/log_subscriber.rb +45 -0
  212. data/sunspot_rails/lib/sunspot/rails/railtie.rb +41 -0
  213. data/sunspot_rails/lib/sunspot/rails/railties/controller_runtime.rb +36 -0
  214. data/sunspot_rails/lib/sunspot/rails/request_lifecycle.rb +36 -0
  215. data/sunspot_rails/lib/sunspot/rails/searchable.rb +495 -0
  216. data/sunspot_rails/lib/sunspot/rails/server.rb +106 -0
  217. data/sunspot_rails/lib/sunspot/rails/solr_instrumentation.rb +19 -0
  218. data/sunspot_rails/lib/sunspot/rails/solr_logging.rb +62 -0
  219. data/sunspot_rails/lib/sunspot/rails/spec_helper.rb +26 -0
  220. data/sunspot_rails/lib/sunspot/rails/stub_session_proxy.rb +146 -0
  221. data/sunspot_rails/lib/sunspot/rails/tasks.rb +94 -0
  222. data/sunspot_rails/lib/sunspot/rails.rb +69 -0
  223. data/sunspot_rails/lib/sunspot_rails.rb +12 -0
  224. data/sunspot_rails/spec/configuration_spec.rb +209 -0
  225. data/sunspot_rails/spec/model_lifecycle_spec.rb +63 -0
  226. data/sunspot_rails/spec/model_spec.rb +601 -0
  227. data/sunspot_rails/spec/rails_template/app/controllers/application_controller.rb +10 -0
  228. data/sunspot_rails/spec/rails_template/app/controllers/posts_controller.rb +6 -0
  229. data/sunspot_rails/spec/rails_template/app/models/author.rb +10 -0
  230. data/sunspot_rails/spec/rails_template/app/models/blog.rb +14 -0
  231. data/sunspot_rails/spec/rails_template/app/models/location.rb +3 -0
  232. data/sunspot_rails/spec/rails_template/app/models/photo_post.rb +2 -0
  233. data/sunspot_rails/spec/rails_template/app/models/post.rb +13 -0
  234. data/sunspot_rails/spec/rails_template/app/models/post_with_auto.rb +12 -0
  235. data/sunspot_rails/spec/rails_template/app/models/post_with_default_scope.rb +13 -0
  236. data/sunspot_rails/spec/rails_template/config/boot.rb +127 -0
  237. data/sunspot_rails/spec/rails_template/config/preinitializer.rb +22 -0
  238. data/sunspot_rails/spec/rails_template/config/routes.rb +9 -0
  239. data/sunspot_rails/spec/rails_template/config/sunspot.yml +24 -0
  240. data/sunspot_rails/spec/rails_template/db/schema.rb +27 -0
  241. data/sunspot_rails/spec/request_lifecycle_spec.rb +61 -0
  242. data/sunspot_rails/spec/schema.rb +27 -0
  243. data/sunspot_rails/spec/searchable_spec.rb +12 -0
  244. data/sunspot_rails/spec/server_spec.rb +33 -0
  245. data/sunspot_rails/spec/session_spec.rb +57 -0
  246. data/sunspot_rails/spec/shared_examples/indexed_after_save.rb +8 -0
  247. data/sunspot_rails/spec/shared_examples/not_indexed_after_save.rb +8 -0
  248. data/sunspot_rails/spec/spec_helper.rb +48 -0
  249. data/sunspot_rails/spec/stub_session_proxy_spec.rb +122 -0
  250. data/sunspot_rails/sunspot_rails.gemspec +43 -0
  251. data/sunspot_rails/tmp/.gitkeep +0 -0
  252. data/sunspot_solr/Gemfile +3 -0
  253. data/sunspot_solr/README.rdoc +24 -0
  254. data/sunspot_solr/bin/sunspot-installer +20 -0
  255. data/sunspot_solr/bin/sunspot-solr +80 -0
  256. data/sunspot_solr/lib/sunspot/solr/installer/config_installer.rb +46 -0
  257. data/sunspot_solr/lib/sunspot/solr/installer/task_helper.rb +13 -0
  258. data/sunspot_solr/lib/sunspot/solr/installer.rb +25 -0
  259. data/sunspot_solr/lib/sunspot/solr/java.rb +10 -0
  260. data/sunspot_solr/lib/sunspot/solr/railtie.rb +15 -0
  261. data/sunspot_solr/lib/sunspot/solr/server.rb +223 -0
  262. data/sunspot_solr/lib/sunspot/solr/tasks.rb +49 -0
  263. data/sunspot_solr/lib/sunspot_solr.rb +5 -0
  264. data/sunspot_solr/solr/README.txt +42 -0
  265. data/sunspot_solr/solr/etc/jetty.xml +219 -0
  266. data/sunspot_solr/solr/etc/webdefault.xml +379 -0
  267. data/sunspot_solr/solr/lib/jetty-6.1.26-patched-JETTY-1340.jar +0 -0
  268. data/sunspot_solr/solr/lib/jetty-util-6.1.26-patched-JETTY-1340.jar +0 -0
  269. data/sunspot_solr/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
  270. data/sunspot_solr/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
  271. data/sunspot_solr/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
  272. data/sunspot_solr/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
  273. data/sunspot_solr/solr/lib/servlet-api-2.5-20081211.jar +0 -0
  274. data/sunspot_solr/solr/solr/.gitignore +1 -0
  275. data/sunspot_solr/solr/solr/README.txt +54 -0
  276. data/sunspot_solr/solr/solr/conf/admin-extra.html +31 -0
  277. data/sunspot_solr/solr/solr/conf/elevate.xml +36 -0
  278. data/sunspot_solr/solr/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  279. data/sunspot_solr/solr/solr/conf/protwords.txt +21 -0
  280. data/sunspot_solr/solr/solr/conf/schema.xml +250 -0
  281. data/sunspot_solr/solr/solr/conf/scripts.conf +24 -0
  282. data/sunspot_solr/solr/solr/conf/solrconfig.xml +934 -0
  283. data/sunspot_solr/solr/solr/conf/spellings.txt +2 -0
  284. data/sunspot_solr/solr/solr/conf/stopwords.txt +58 -0
  285. data/sunspot_solr/solr/solr/conf/synonyms.txt +31 -0
  286. data/sunspot_solr/solr/solr/conf/xslt/example.xsl +132 -0
  287. data/sunspot_solr/solr/solr/conf/xslt/example_atom.xsl +67 -0
  288. data/sunspot_solr/solr/solr/conf/xslt/example_rss.xsl +66 -0
  289. data/sunspot_solr/solr/solr/conf/xslt/luke.xsl +337 -0
  290. data/sunspot_solr/solr/start.jar +0 -0
  291. data/sunspot_solr/solr/webapps/solr.war +0 -0
  292. data/sunspot_solr/spec/server_spec.rb +98 -0
  293. data/sunspot_solr/spec/spec_helper.rb +18 -0
  294. data/sunspot_solr/sunspot_solr.gemspec +37 -0
  295. data/tools/gem_tasks.rb +69 -0
  296. metadata +353 -343
  297. data/lib/sunspot/search/field_group.rb +0 -46
  298. data/lib/sunspot/version.rb +0 -3
  299. data/spec/api/adapters_spec.rb +0 -33
@@ -0,0 +1,146 @@
1
+ module Sunspot
2
+ module Rails
3
+ class StubSessionProxy
4
+ attr_reader :original_session
5
+
6
+ def initialize(original_session)
7
+ @original_session = original_session
8
+ end
9
+
10
+ def index(*objects)
11
+ end
12
+
13
+ def index!(*objects)
14
+ end
15
+
16
+ def remove(*objects)
17
+ end
18
+
19
+ def remove!(*objects)
20
+ end
21
+
22
+ def remove_by_id(clazz, id)
23
+ end
24
+
25
+ def remove_by_id!(clazz, id)
26
+ end
27
+
28
+ def remove_all(clazz = nil)
29
+ end
30
+
31
+ def remove_all!(clazz = nil)
32
+ end
33
+
34
+ def dirty?
35
+ false
36
+ end
37
+
38
+ def delete_dirty?
39
+ false
40
+ end
41
+
42
+ def commit_if_dirty
43
+ end
44
+
45
+ def commit_if_delete_dirty
46
+ end
47
+
48
+ def commit
49
+ end
50
+
51
+ def search(*types)
52
+ Search.new
53
+ end
54
+
55
+ def new_search(*types)
56
+ Search.new
57
+ end
58
+
59
+ def more_like_this(*args)
60
+ Search.new
61
+ end
62
+
63
+ def new_more_like_this(*args)
64
+ Search.new
65
+ end
66
+
67
+ class Search
68
+
69
+ def build
70
+ self
71
+ end
72
+
73
+ def results
74
+ PaginatedCollection.new
75
+ end
76
+
77
+ def hits(options = {})
78
+ PaginatedCollection.new
79
+ end
80
+
81
+ def total
82
+ 0
83
+ end
84
+
85
+ def facet(name)
86
+ end
87
+
88
+ def dynamic_facet(name)
89
+ end
90
+
91
+ def execute
92
+ self
93
+ end
94
+ end
95
+
96
+
97
+ class PaginatedCollection < Array
98
+
99
+ def total_count
100
+ 0
101
+ end
102
+ alias :total_entries :total_count
103
+
104
+ def current_page
105
+ 1
106
+ end
107
+
108
+ def per_page
109
+ 30
110
+ end
111
+ alias :limit_value :per_page
112
+
113
+ def total_pages
114
+ 1
115
+ end
116
+ alias :num_pages :total_pages
117
+
118
+ def first_page?
119
+ true
120
+ end
121
+
122
+ def last_page?
123
+ true
124
+ end
125
+
126
+ def previous_page
127
+ nil
128
+ end
129
+
130
+ def next_page
131
+ nil
132
+ end
133
+
134
+ def out_of_bounds?
135
+ false
136
+ end
137
+
138
+ def offset
139
+ 0
140
+ end
141
+
142
+ end
143
+
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,94 @@
1
+ namespace :sunspot do
2
+
3
+ desc "Reindex all solr models that are located in your application's models directory."
4
+ # This task depends on the standard Rails file naming \
5
+ # conventions, in that the file name matches the defined class name. \
6
+ # By default the indexing system works in batches of 50 records, you can \
7
+ # set your own value for this by using the batch_size argument. You can \
8
+ # also optionally define a list of models to separated by a forward slash '/'
9
+ #
10
+ # $ rake sunspot:reindex # reindex all models
11
+ # $ rake sunspot:reindex[1000] # reindex in batches of 1000
12
+ # $ rake sunspot:reindex[false] # reindex without batching
13
+ # $ rake sunspot:reindex[,Post] # reindex only the Post model
14
+ # $ rake sunspot:reindex[1000,Post] # reindex only the Post model in
15
+ # # batchs of 1000
16
+ # $ rake sunspot:reindex[,Post+Author] # reindex Post and Author model
17
+ task :reindex, [:batch_size, :models] => [:environment] do |t, args|
18
+
19
+ # Retry once or gracefully fail for a 5xx error so we don't break reindexing
20
+ Sunspot.session = Sunspot::SessionProxy::Retry5xxSessionProxy.new(Sunspot.session)
21
+
22
+ # Set up general options for reindexing
23
+ reindex_options = { :batch_commit => false }
24
+
25
+ case args[:batch_size]
26
+ when 'false'
27
+ reindex_options[:batch_size] = nil
28
+ when /^\d+$/
29
+ reindex_options[:batch_size] = args[:batch_size].to_i if args[:batch_size].to_i > 0
30
+ end
31
+
32
+ # Load all the application's models. Models which invoke 'searchable' will register themselves
33
+ # in Sunspot.searchable.
34
+ Dir.glob(Rails.root.join('app/models/**/*.rb')).each { |path| require path }
35
+
36
+ # By default, reindex all searchable models
37
+ sunspot_models = Sunspot.searchable
38
+
39
+ # Choose a specific subset of models, if requested
40
+ if args[:models]
41
+ model_names = args[:models].split('+')
42
+ sunspot_models = model_names.map{ |m| m.constantize }
43
+ end
44
+
45
+ # Set up progress_bar to, ah, report progress
46
+ begin
47
+ require 'progress_bar'
48
+ total_documents = sunspot_models.map { | m | m.count }.sum
49
+ reindex_options[:progress_bar] = ProgressBar.new(total_documents)
50
+ rescue LoadError => e
51
+ $stdout.puts "Skipping progress bar: for progress reporting, add gem 'progress_bar' to your Gemfile"
52
+ rescue Exception => e
53
+ $stderr.puts "Error using progress bar: #{e.message}"
54
+ end
55
+
56
+ # Finally, invoke the class-level solr_reindex on each model
57
+ sunspot_models.each do |model|
58
+ model.solr_reindex(reindex_options)
59
+ end
60
+ end
61
+
62
+ def sunspot_solr_in_load_path?
63
+ # http://www.rubular.com/r/rJGDh7eOSc
64
+ $:.any? { |path| path =~ %r{sunspot_solr(-[^/]+)?/lib$} }
65
+ end
66
+
67
+ unless sunspot_solr_in_load_path?
68
+ namespace :solr do
69
+ task :moved_to_sunspot_solr do
70
+ abort %(
71
+ Note: This task has been moved to the sunspot_solr gem. To install, start and
72
+ stop a local Solr instance, please add sunspot_solr to your Gemfile:
73
+
74
+ group :development do
75
+ gem 'sunspot_solr'
76
+ end
77
+
78
+ )
79
+ end
80
+
81
+ desc 'Start the Solr instance'
82
+ task :start => :moved_to_sunspot_solr
83
+
84
+ desc 'Run the Solr instance in the foreground'
85
+ task :run => :moved_to_sunspot_solr
86
+
87
+ desc 'Stop the Solr instance'
88
+ task :stop => :moved_to_sunspot_solr
89
+
90
+ # for backwards compatibility
91
+ task :reindex => :"sunspot:reindex"
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,69 @@
1
+ require 'sunspot'
2
+ require File.join(File.dirname(__FILE__), 'rails', 'configuration')
3
+ require File.join(File.dirname(__FILE__), 'rails', 'adapters')
4
+ require File.join(File.dirname(__FILE__), 'rails', 'request_lifecycle')
5
+ require File.join(File.dirname(__FILE__), 'rails', 'searchable')
6
+
7
+ module Sunspot #:nodoc:
8
+ module Rails #:nodoc:
9
+ autoload :SolrInstrumentation, File.join(File.dirname(__FILE__), 'rails', 'solr_instrumentation')
10
+ autoload :StubSessionProxy, File.join(File.dirname(__FILE__), 'rails', 'stub_session_proxy')
11
+ begin
12
+ require 'sunspot_solr'
13
+ autoload :Server, File.join(File.dirname(__FILE__), 'rails', 'server')
14
+ rescue LoadError => e
15
+ # We're fine
16
+ end
17
+
18
+ class <<self
19
+ attr_writer :configuration
20
+
21
+ def configuration
22
+ @configuration ||= Sunspot::Rails::Configuration.new
23
+ end
24
+
25
+ def reset
26
+ @configuration = nil
27
+ end
28
+
29
+ def build_session(configuration = self.configuration)
30
+ if configuration.disabled?
31
+ StubSessionProxy.new(Sunspot.session)
32
+ elsif configuration.has_master?
33
+ SessionProxy::MasterSlaveSessionProxy.new(
34
+ SessionProxy::ThreadLocalSessionProxy.new(master_config(configuration)),
35
+ SessionProxy::ThreadLocalSessionProxy.new(slave_config(configuration))
36
+ )
37
+ else
38
+ SessionProxy::ThreadLocalSessionProxy.new(slave_config(configuration))
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def master_config(sunspot_rails_configuration)
45
+ config = Sunspot::Configuration.build
46
+ config.solr.url = URI::HTTP.build(
47
+ :host => sunspot_rails_configuration.master_hostname,
48
+ :port => sunspot_rails_configuration.master_port,
49
+ :path => sunspot_rails_configuration.master_path
50
+ ).to_s
51
+ config.solr.read_timeout = sunspot_rails_configuration.read_timeout
52
+ config.solr.open_timeout = sunspot_rails_configuration.open_timeout
53
+ config
54
+ end
55
+
56
+ def slave_config(sunspot_rails_configuration)
57
+ config = Sunspot::Configuration.build
58
+ config.solr.url = URI::HTTP.build(
59
+ :host => sunspot_rails_configuration.hostname,
60
+ :port => sunspot_rails_configuration.port,
61
+ :path => sunspot_rails_configuration.path
62
+ ).to_s
63
+ config.solr.read_timeout = sunspot_rails_configuration.read_timeout
64
+ config.solr.open_timeout = sunspot_rails_configuration.open_timeout
65
+ config
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,12 @@
1
+ # This needs to be loaded before sunspot/search/paginated_collection
2
+ # or #to_json gets defined in Object breaking delegation to Array via
3
+ # method_missing
4
+ require 'active_support/core_ext/object/to_json' if Rails::VERSION::MAJOR == 3
5
+
6
+ require 'sunspot/rails'
7
+
8
+ if Rails::VERSION::MAJOR == 3
9
+ require 'sunspot/rails/railtie'
10
+ else
11
+ require 'sunspot/rails/init'
12
+ end
@@ -0,0 +1,209 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ describe Sunspot::Rails::Configuration, "default values without a sunspot.yml" do
4
+ before(:each) do
5
+ File.stub!(:exist?).and_return(false) # simulate sunspot.yml not existing
6
+ @config = Sunspot::Rails::Configuration.new
7
+ end
8
+
9
+ it "should handle the 'hostname' property when not set" do
10
+ @config.hostname.should == 'localhost'
11
+ end
12
+
13
+ it "should handle the 'path' property when not set" do
14
+ @config.path.should == '/solr'
15
+ end
16
+
17
+ describe "port" do
18
+ it "should default to port 8981 in test" do
19
+ ::Rails.stub!(:env => 'test')
20
+ @config = Sunspot::Rails::Configuration.new
21
+ @config.port.should == 8981
22
+ end
23
+ it "should default to port 8982 in development" do
24
+ ::Rails.stub!(:env => 'development')
25
+ @config = Sunspot::Rails::Configuration.new
26
+ @config.port.should == 8982
27
+ end
28
+ it "should default to 8983 in production" do
29
+ ::Rails.stub!(:env => 'production')
30
+ @config = Sunspot::Rails::Configuration.new
31
+ @config.port.should == 8983
32
+ end
33
+ it "should generally default to 8983" do
34
+ ::Rails.stub!(:env => 'staging')
35
+ @config = Sunspot::Rails::Configuration.new
36
+ @config.port.should == 8983
37
+ end
38
+ end
39
+
40
+ it "should set the read timeout to nil when not set" do
41
+ @config.read_timeout == nil
42
+ end
43
+
44
+ it "should set the open timeout to nil when not set" do
45
+ @config.open_timeout == nil
46
+ end
47
+
48
+ it "should handle the 'log_level' property when not set" do
49
+ @config.log_level.should == 'INFO'
50
+ end
51
+
52
+ it "should handle the 'log_file' property" do
53
+ @config.log_file.should =~ /log\/solr_test.log/
54
+ end
55
+
56
+ it "should handle the 'solr_home' property when not set" do
57
+ Rails.should_receive(:root).at_least(1).and_return('/some/path')
58
+ @config.solr_home.should == '/some/path/solr'
59
+ end
60
+
61
+ it "should handle the 'data_path' property when not set" do
62
+ Rails.should_receive(:root).at_least(1).and_return('/some/path')
63
+ @config.data_path.should == '/some/path/solr/data/test'
64
+ end
65
+
66
+ it "should handle the 'pid_dir' property when not set" do
67
+ Rails.should_receive(:root).at_least(1).and_return('/some/path')
68
+ @config.pid_dir.should == '/some/path/solr/pids/test'
69
+ end
70
+
71
+ it "should handle the 'auto_commit_after_request' propery when not set" do
72
+ @config.auto_commit_after_request?.should == true
73
+ end
74
+
75
+ it "should handle the 'auto_commit_after_delete_request' propery when not set" do
76
+ @config.auto_commit_after_delete_request?.should == false
77
+ end
78
+
79
+ it "should handle the 'bind_address' property when not set" do
80
+ @config.bind_address.should be_nil
81
+ end
82
+
83
+ it "should handle the 'disabled' property when not set" do
84
+ @config.disabled?.should be_false
85
+ end
86
+ end
87
+
88
+ describe Sunspot::Rails::Configuration, "user provided sunspot.yml" do
89
+ before(:each) do
90
+ ::Rails.stub!(:env => 'config_test')
91
+ @config = Sunspot::Rails::Configuration.new
92
+ end
93
+
94
+ it "should handle the 'hostname' property when set" do
95
+ @config.hostname.should == 'some.host'
96
+ end
97
+
98
+ it "should handle the 'port' property when set" do
99
+ @config.port.should == 1234
100
+ end
101
+
102
+ it "should handle the 'path' property when set" do
103
+ @config.path.should == '/solr/idx'
104
+ end
105
+
106
+ it "should handle the 'log_level' propery when set" do
107
+ @config.log_level.should == 'WARNING'
108
+ end
109
+
110
+ it "should handle the 'solr_home' propery when set" do
111
+ @config.solr_home.should == '/my_superior_path'
112
+ end
113
+
114
+ it "should handle the 'data_path' property when set" do
115
+ @config.data_path.should == '/my_superior_path/data'
116
+ end
117
+
118
+ it "should handle the 'pid_dir' property when set" do
119
+ @config.pid_dir.should == '/my_superior_path/pids'
120
+ end
121
+
122
+ it "should handle the 'solr_home' property when set" do
123
+ @config.solr_home.should == '/my_superior_path'
124
+ end
125
+
126
+ it "should handle the 'auto_commit_after_request' propery when set" do
127
+ @config.auto_commit_after_request?.should == false
128
+ end
129
+
130
+ it "should handle the 'auto_commit_after_delete_request' propery when set" do
131
+ @config.auto_commit_after_delete_request?.should == true
132
+ end
133
+
134
+ it "should handle the 'bind_address' property when set" do
135
+ @config.bind_address.should == "127.0.0.1"
136
+ end
137
+ it "should handle the 'read_timeout' property when set" do
138
+ @config.read_timeout.should == 2
139
+ end
140
+ it "should handle the 'open_timeout' property when set" do
141
+ @config.open_timeout.should == 0.5
142
+ end
143
+ end
144
+
145
+ describe Sunspot::Rails::Configuration, "with disabled: true in sunspot.yml" do
146
+ before(:each) do
147
+ ::Rails.stub!(:env => 'config_disabled_test')
148
+ @config = Sunspot::Rails::Configuration.new
149
+ end
150
+
151
+ it "should handle the 'disabled' property when set" do
152
+ @config.disabled?.should be_true
153
+ end
154
+ end
155
+
156
+ describe Sunspot::Rails::Configuration, "with ENV['SOLR_URL'] overriding sunspot.yml" do
157
+ before(:all) do
158
+ ENV['SOLR_URL'] = 'http://environment.host:5432/solr/env'
159
+ end
160
+
161
+ before(:each) do
162
+ ::Rails.stub!(:env => 'config_test')
163
+ @config = Sunspot::Rails::Configuration.new
164
+ end
165
+
166
+ after(:all) do
167
+ ENV.delete('SOLR_URL')
168
+ end
169
+
170
+ it "should handle the 'hostname' property when set" do
171
+ @config.hostname.should == 'environment.host'
172
+ end
173
+
174
+ it "should handle the 'port' property when set" do
175
+ @config.port.should == 5432
176
+ end
177
+
178
+ it "should handle the 'path' property when set" do
179
+ @config.path.should == '/solr/env'
180
+ end
181
+ end
182
+
183
+ describe Sunspot::Rails::Configuration, "with ENV['WEBSOLR_URL'] overriding sunspot.yml" do
184
+ before(:all) do
185
+ ENV['WEBSOLR_URL'] = 'http://index.websolr.test/solr/a1b2c3d4e5f'
186
+ end
187
+
188
+ before(:each) do
189
+ ::Rails.stub!(:env => 'config_test')
190
+ @config = Sunspot::Rails::Configuration.new
191
+ end
192
+
193
+ after(:all) do
194
+ ENV.delete('WEBSOLR_URL')
195
+ end
196
+
197
+ it "should handle the 'hostname' property when set" do
198
+ @config.hostname.should == 'index.websolr.test'
199
+ end
200
+
201
+ it "should handle the 'port' property when set" do
202
+ @config.port.should == 80
203
+ end
204
+
205
+ it "should handle the 'path' property when set" do
206
+ @config.path.should == '/solr/a1b2c3d4e5f'
207
+ end
208
+ end
209
+
@@ -0,0 +1,63 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ describe 'searchable with lifecycle' do
4
+ describe 'on create' do
5
+ before :each do
6
+ @post = PostWithAuto.create
7
+ Sunspot.commit
8
+ end
9
+
10
+ it 'should automatically index' do
11
+ PostWithAuto.search.results.should == [@post]
12
+ end
13
+ end
14
+
15
+ describe 'on update' do
16
+ before :each do
17
+ @post = PostWithAuto.create
18
+ @post.update_attributes(:title => 'Test 1')
19
+ Sunspot.commit
20
+ end
21
+
22
+ it 'should automatically update index' do
23
+ PostWithAuto.search { with :title, 'Test 1' }.results.should == [@post]
24
+ end
25
+
26
+ it "should index model if relevant attribute changed" do
27
+ @post = PostWithAuto.create!
28
+ @post.title = 'new title'
29
+ @post.should_receive :solr_index
30
+ @post.save!
31
+ end
32
+
33
+ it "should not index model if relevant attribute not changed" do
34
+ @post = PostWithAuto.create!
35
+ @post.updated_at = Date.tomorrow
36
+ @post.should_not_receive :solr_index
37
+ @post.save!
38
+ end
39
+ end
40
+
41
+ describe 'on destroy' do
42
+ before :each do
43
+ @post = PostWithAuto.create
44
+ @post.destroy
45
+ Sunspot.commit
46
+ end
47
+
48
+ it 'should automatically remove it from the index' do
49
+ PostWithAuto.search_ids.should be_empty
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'searchable with lifecycle - ignoring specific attributes' do
55
+ before(:each) do
56
+ @post = PostWithAuto.create
57
+ end
58
+
59
+ it "should not reindex the object on an update_at change, because it is marked as to-ignore" do
60
+ Sunspot.should_not_receive(:index).with(@post)
61
+ @post.update_attribute :updated_at, 123.seconds.from_now
62
+ end
63
+ end