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,601 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ describe 'ActiveRecord mixin' do
4
+ describe 'index()' do
5
+ before :each do
6
+ @post = Post.create!
7
+ @post.index
8
+ end
9
+
10
+ it 'should not commit the model' do
11
+ Post.search.results.should be_empty
12
+ end
13
+
14
+ it 'should index the model' do
15
+ Sunspot.commit
16
+ Post.search.results.should == [@post]
17
+ end
18
+
19
+ it "should not blow up if there's a default scope specifying order" do
20
+ posts = Array.new(2) { |j| PostWithDefaultScope.create! :title => (10-j).to_s }
21
+ lambda { PostWithDefaultScope.index(:batch_size => 1) }.should_not raise_error
22
+ end
23
+ end
24
+
25
+ describe 'single table inheritence' do
26
+ before :each do
27
+ @post = PhotoPost.create!
28
+ end
29
+
30
+ it 'should not break auto-indexing' do
31
+ @post.title = 'Title'
32
+ lambda { @post.save! }.should_not raise_error
33
+ end
34
+ end
35
+
36
+ describe 'index!()' do
37
+ before :each do
38
+ @post = Post.create!
39
+ @post.index!
40
+ end
41
+
42
+ it 'should immediately index and commit' do
43
+ Post.search.results.should == [@post]
44
+ end
45
+ end
46
+
47
+ describe 'remove_from_index()' do
48
+ before :each do
49
+ @post = Post.create!
50
+ @post.index!
51
+ @post.remove_from_index
52
+ end
53
+
54
+ it 'should not commit immediately' do
55
+ Post.search.results.should == [@post]
56
+ end
57
+
58
+ it 'should remove the model from the index' do
59
+ Sunspot.commit
60
+ Post.search.results.should be_empty
61
+ end
62
+ end
63
+
64
+ describe 'remove_from_index!()' do
65
+ before :each do
66
+ @post = Post.create!
67
+ @post.index!
68
+ @post.remove_from_index!
69
+ end
70
+
71
+ it 'should immediately remove the model and commit' do
72
+ Post.search.results.should be_empty
73
+ end
74
+ end
75
+
76
+ describe 'remove_all_from_index' do
77
+ before :each do
78
+ @posts = Array.new(2) { Post.create! }.each { |post| Sunspot.index(post) }
79
+ Sunspot.commit
80
+ Post.remove_all_from_index
81
+ end
82
+
83
+ it 'should not commit immediately' do
84
+ Post.search.results.to_set.should == @posts.to_set
85
+ end
86
+
87
+ it 'should remove all instances from the index' do
88
+ Sunspot.commit
89
+ Post.search.results.should be_empty
90
+ end
91
+ end
92
+
93
+ describe 'remove_all_from_index!' do
94
+ before :each do
95
+ Array.new(2) { Post.create! }.each { |post| Sunspot.index(post) }
96
+ Sunspot.commit
97
+ Post.remove_all_from_index!
98
+ end
99
+
100
+ it 'should remove all instances from the index and commit immediately' do
101
+ Post.search.results.should be_empty
102
+ end
103
+ end
104
+
105
+ describe 'search()' do
106
+ before :each do
107
+ @post = Post.create!(:title => 'Test Post')
108
+ @post.index!
109
+ end
110
+
111
+ it 'should return results specified by search' do
112
+ Post.search do
113
+ with :title, 'Test Post'
114
+ end.results.should == [@post]
115
+ end
116
+
117
+ it 'should not return results excluded by search' do
118
+ Post.search do
119
+ with :title, 'Bogus Post'
120
+ end.results.should be_empty
121
+ end
122
+
123
+ it 'should use the include option on the data accessor when specified' do
124
+ Post.should_receive(:all).with(hash_including(:include => [:blog])).and_return([@post])
125
+ Post.search do
126
+ with :title, 'Test Post'
127
+ data_accessor_for(Post).include = [:blog]
128
+ end.results.should == [@post]
129
+ end
130
+
131
+ it 'should pass :include option from search call to data accessor' do
132
+ Post.should_receive(:all).with(hash_including(:include => [:blog])).and_return([@post])
133
+ Post.search(:include => [:blog]) do
134
+ with :title, 'Test Post'
135
+ end.results.should == [@post]
136
+ end
137
+
138
+ it 'should use the select option from search call to data accessor' do
139
+ Post.should_receive(:all).with(hash_including(:select => 'title, published_at')).and_return([@post])
140
+ Post.search(:select => 'title, published_at') do
141
+ with :title, 'Test Post'
142
+ end.results.should == [@post]
143
+ end
144
+
145
+ it 'should not allow bogus options to search' do
146
+ lambda { Post.search(:bogus => :option) }.should raise_error(ArgumentError)
147
+ end
148
+
149
+ it 'should use the select option on the data accessor when specified' do
150
+ Post.should_receive(:all).with(hash_including(:select => 'title, published_at')).and_return([@post])
151
+ Post.search do
152
+ with :title, 'Test Post'
153
+ data_accessor_for(Post).select = [:title, :published_at]
154
+ end.results.should == [@post]
155
+ end
156
+
157
+ it 'should not use the select option on the data accessor when not specified' do
158
+ Post.should_receive(:all).with(hash_not_including(:select)).and_return([@post])
159
+ Post.search do
160
+ with :title, 'Test Post'
161
+ end.results.should == [@post]
162
+ end
163
+
164
+ it 'should gracefully handle nonexistent records' do
165
+ post2 = Post.create!(:title => 'Test Post')
166
+ post2.index!
167
+ post2.destroy
168
+ Post.search do
169
+ with :title, 'Test Post'
170
+ end.results.should == [@post]
171
+ end
172
+
173
+ it 'should use an ActiveRecord object for coordinates' do
174
+ post = Post.new(:title => 'Test Post')
175
+ post.location = Location.create!(:lat => 40.0, :lng => -70.0)
176
+ post.save
177
+ post.index!
178
+ Post.search { with(:location).near(40.0, -70.0) }.results.should == [post]
179
+ end
180
+
181
+ end
182
+
183
+ describe 'search_ids()' do
184
+ before :each do
185
+ @posts = Array.new(2) { Post.create! }.each { |post| post.index }
186
+ Sunspot.commit
187
+ end
188
+
189
+ it 'should return IDs' do
190
+ Post.search_ids.to_set.should == @posts.map { |post| post.id }.to_set
191
+ end
192
+ end
193
+
194
+ describe 'searchable?()' do
195
+ it 'should not be true for models that have not been configured for search' do
196
+ Location.should_not be_searchable
197
+ end
198
+
199
+ it 'should be true for models that have been configured for search' do
200
+ Post.should be_searchable
201
+ end
202
+ end
203
+
204
+ describe 'index_orphans()' do
205
+ before :each do
206
+ @posts = Array.new(2) { Post.create }.each { |post| post.index }
207
+ Sunspot.commit
208
+ @posts.first.destroy
209
+ end
210
+
211
+ it 'should return IDs of objects that are in the index but not the database' do
212
+ Post.index_orphans.should == [@posts.first.id]
213
+ end
214
+
215
+ it 'should find the orphans in batches to improve performance' do
216
+ Post.should_receive(:find_each).with(hash_including(:batch_size => 10)).and_return([])
217
+ Post.index_orphans(:batch_size => 10)
218
+ end
219
+
220
+ end
221
+
222
+ describe 'clean_index_orphans()' do
223
+ before :each do
224
+ @posts = Array.new(2) { Post.create }.each { |post| post.index }
225
+ Sunspot.commit
226
+ @posts.first.destroy
227
+ end
228
+
229
+ it 'should remove orphans from the index' do
230
+ Post.clean_index_orphans
231
+ Sunspot.commit
232
+ Post.search.results.should == [@posts.last]
233
+ end
234
+ end
235
+
236
+ describe 'reindex()' do
237
+ before :each do
238
+ @posts = Array.new(2) { Post.create }
239
+ end
240
+
241
+ it 'should index all instances' do
242
+ Post.reindex(:batch_size => nil)
243
+ Sunspot.commit
244
+ Post.search.results.to_set.should == @posts.to_set
245
+ end
246
+
247
+ it 'should remove all currently indexed instances' do
248
+ old_post = Post.create!
249
+ old_post.index!
250
+ old_post.destroy
251
+ Post.reindex
252
+ Sunspot.commit
253
+ Post.search.results.to_set.should == @posts.to_set
254
+ end
255
+
256
+ end
257
+
258
+ describe 'reindex() with real data' do
259
+ before :each do
260
+ @posts = Array.new(2) { Post.create }
261
+ end
262
+
263
+ it 'should index all instances' do
264
+ Post.reindex(:batch_size => nil)
265
+ Sunspot.commit
266
+ Post.search.results.to_set.should == @posts.to_set
267
+ end
268
+
269
+ it 'should remove all currently indexed instances' do
270
+ old_post = Post.create!
271
+ old_post.index!
272
+ old_post.destroy
273
+ Post.reindex
274
+ Sunspot.commit
275
+ Post.search.results.to_set.should == @posts.to_set
276
+ end
277
+
278
+ describe "using batch sizes" do
279
+ it 'should index with a specified batch size' do
280
+ Post.reindex(:batch_size => 1)
281
+ Sunspot.commit
282
+ Post.search.results.to_set.should == @posts.to_set
283
+ end
284
+ end
285
+ end
286
+
287
+
288
+
289
+ describe "reindex()" do
290
+
291
+ before(:each) do
292
+ @posts = Array.new(2) { Post.create }
293
+ end
294
+
295
+ describe "when not using batches" do
296
+
297
+ it "should select all if the batch_size is nil" do
298
+ Post.should_receive(:all).with(:include => []).and_return([])
299
+ Post.reindex(:batch_size => nil)
300
+ end
301
+
302
+ it "should search for models with includes" do
303
+ Post.should_receive(:all).with(:include => :author).and_return([])
304
+ Post.reindex(:batch_size => nil, :include => :author)
305
+ end
306
+
307
+ describe ':if constraints' do
308
+ before do
309
+ Post.sunspot_options[:if] = proc { |model| model.id != @posts.first.id }
310
+ end
311
+
312
+ after do
313
+ Post.sunspot_options[:if] = nil
314
+ end
315
+
316
+ it 'should only index those models where :if constraints pass' do
317
+ Post.reindex(:batch_size => nil)
318
+
319
+ Post.search.results.should_not include(@posts.first)
320
+ end
321
+ end
322
+
323
+ end
324
+
325
+ describe "when using batches" do
326
+ it "should commit after indexing each batch" do
327
+ Sunspot.should_receive(:commit).twice
328
+ Post.reindex(:batch_size => 1)
329
+ end
330
+
331
+ it "should commit after indexing everything" do
332
+ Sunspot.should_receive(:commit).once
333
+ Post.reindex(:batch_commit => false)
334
+ end
335
+
336
+ describe ':if constraints' do
337
+ before do
338
+ Post.sunspot_options[:if] = proc { |model| model.id != @posts.first.id }
339
+ end
340
+
341
+ after do
342
+ Post.sunspot_options[:if] = nil
343
+ end
344
+
345
+ it 'should only index those models where :if constraints pass' do
346
+ Post.reindex(:batch_size => 50)
347
+
348
+ Post.search.results.should_not include(@posts.first)
349
+ end
350
+ end
351
+ end
352
+ end
353
+
354
+ describe "more_like_this()" do
355
+ before(:each) do
356
+ @posts = [
357
+ Post.create!(:title => 'Post123', :body => "one two three"),
358
+ Post.create!(:title => 'Post345', :body => "three four five"),
359
+ Post.create!(:title => 'Post456', :body => "four five six"),
360
+ Post.create!(:title => 'Post234', :body => "two three four"),
361
+ ]
362
+ @posts_with_auto = [
363
+ PostWithAuto.create!(:body => "one two three"),
364
+ PostWithAuto.create!(:body => "four five six")
365
+ ]
366
+ @posts.each { |p| p.index! }
367
+ end
368
+
369
+ it "should return results" do
370
+ @posts.first.more_like_this.results.should == [@posts[3], @posts[1]]
371
+ end
372
+
373
+ it "should return results for specified classes" do
374
+ @posts.first.more_like_this(Post, PostWithAuto).results.to_set.should ==
375
+ Set[@posts_with_auto[0], @posts[1], @posts[3]]
376
+ end
377
+ end
378
+
379
+ describe 'more_like_this_ids()' do
380
+ before :each do
381
+ @posts = [
382
+ Post.create!(:title => 'Post123', :body => "one two three"),
383
+ Post.create!(:title => 'Post345', :body => "three four five"),
384
+ Post.create!(:title => 'Post456', :body => "four five six"),
385
+ Post.create!(:title => 'Post234', :body => "two three four"),
386
+ ]
387
+ @posts.each { |p| p.index! }
388
+ end
389
+
390
+ it 'should return IDs' do
391
+ @posts.first.more_like_this_ids.to_set.should == [@posts[3], @posts[1]].map { |post| post.id }.to_set
392
+ end
393
+ end
394
+
395
+ describe ':if constraint' do
396
+ subject do
397
+ PostWithAuto.new(:title => 'Post123')
398
+ end
399
+
400
+ after do
401
+ subject.class.sunspot_options[:if] = nil
402
+ end
403
+
404
+ context 'Symbol' do
405
+ context 'constraint returns true' do
406
+ # searchable :if => :returns_true
407
+ before do
408
+ subject.should_receive(:returns_true).and_return(true)
409
+ subject.class.sunspot_options[:if] = :returns_true
410
+ end
411
+
412
+ it_should_behave_like 'indexed after save'
413
+ end
414
+
415
+ context 'constraint returns false' do
416
+ # searchable :if => :returns_false
417
+ before do
418
+ subject.should_receive(:returns_false).and_return(false)
419
+ subject.class.sunspot_options[:if] = :returns_false
420
+ end
421
+
422
+ it_should_behave_like 'not indexed after save'
423
+ end
424
+ end
425
+
426
+ context 'String' do
427
+ context 'constraint returns true' do
428
+ # searchable :if => 'returns_true'
429
+ before do
430
+ subject.should_receive(:returns_true).and_return(true)
431
+ subject.class.sunspot_options[:if] = 'returns_true'
432
+ end
433
+
434
+ it_should_behave_like 'indexed after save'
435
+ end
436
+
437
+ context 'constraint returns false' do
438
+ # searchable :if => 'returns_false'
439
+ before do
440
+ subject.should_receive(:returns_false).and_return(false)
441
+ subject.class.sunspot_options[:if] = 'returns_false'
442
+ end
443
+
444
+ it_should_behave_like 'not indexed after save'
445
+ end
446
+ end
447
+
448
+ context 'Proc' do
449
+ context 'constraint returns true' do
450
+ # searchable :if => proc { true }
451
+ before do
452
+ subject.class.sunspot_options[:if] = proc { true }
453
+ end
454
+
455
+ it_should_behave_like 'indexed after save'
456
+ end
457
+
458
+ context 'constraint returns false' do
459
+ # searchable :if => proc { false }
460
+ before do
461
+ subject.class.sunspot_options[:if] = proc { false }
462
+ end
463
+
464
+ it_should_behave_like 'not indexed after save'
465
+ end
466
+ end
467
+
468
+ context 'Array' do
469
+ context 'all constraints returns true' do
470
+ # searchable :if => [:returns_true_1, :returns_true_2]
471
+ before do
472
+ subject.should_receive(:returns_true_1).and_return(true)
473
+ subject.should_receive(:returns_true_2).and_return(true)
474
+ subject.class.sunspot_options[:if] = [:returns_true_1, 'returns_true_2']
475
+ end
476
+
477
+ it_should_behave_like 'indexed after save'
478
+ end
479
+
480
+ context 'one constraint returns false' do
481
+ # searchable :if => [:returns_true, :returns_false]
482
+ before do
483
+ subject.should_receive(:returns_true).and_return(true)
484
+ subject.should_receive(:returns_false).and_return(false)
485
+ subject.class.sunspot_options[:if] = [:returns_true, 'returns_false']
486
+ end
487
+
488
+ it_should_behave_like 'not indexed after save'
489
+ end
490
+ end
491
+
492
+ it 'removes the model from the index if the constraint does not match' do
493
+ subject.save!
494
+ Sunspot.commit
495
+ subject.class.search.results.should include(subject)
496
+
497
+ subject.class.sunspot_options[:if] = proc { false }
498
+ subject.save!
499
+ Sunspot.commit
500
+ subject.class.search.results.should_not include(subject)
501
+ end
502
+ end
503
+
504
+ describe ':unless constraint' do
505
+ subject do
506
+ PostWithAuto.new(:title => 'Post123')
507
+ end
508
+
509
+ after do
510
+ subject.class.sunspot_options[:unless] = nil
511
+ end
512
+
513
+ context 'Symbol' do
514
+ context 'constraint returns true' do
515
+ # searchable :unless => :returns_true
516
+ before do
517
+ subject.should_receive(:returns_true).and_return(true)
518
+ subject.class.sunspot_options[:unless] = :returns_true
519
+ end
520
+
521
+ it_should_behave_like 'not indexed after save'
522
+ end
523
+
524
+ context 'constraint returns false' do
525
+ # searchable :unless => :returns_false
526
+ before do
527
+ subject.should_receive(:returns_false).and_return(false)
528
+ subject.class.sunspot_options[:unless] = :returns_false
529
+ end
530
+
531
+ it_should_behave_like 'indexed after save'
532
+ end
533
+ end
534
+
535
+ context 'String' do
536
+ context 'constraint returns true' do
537
+ # searchable :unless => 'returns_true'
538
+ before do
539
+ subject.should_receive(:returns_true).and_return(true)
540
+ subject.class.sunspot_options[:unless] = 'returns_true'
541
+ end
542
+
543
+ it_should_behave_like 'not indexed after save'
544
+ end
545
+
546
+ context 'constraint returns false' do
547
+ # searchable :unless => 'returns_false'
548
+ before do
549
+ subject.should_receive(:returns_false).and_return(false)
550
+ subject.class.sunspot_options[:unless] = 'returns_false'
551
+ end
552
+
553
+ it_should_behave_like 'indexed after save'
554
+ end
555
+ end
556
+
557
+ context 'Proc' do
558
+ context 'constraint returns true' do
559
+ # searchable :unless => proc { true }
560
+ before do
561
+ subject.class.sunspot_options[:unless] = proc { |model| model == subject } # true
562
+ end
563
+
564
+ it_should_behave_like 'not indexed after save'
565
+ end
566
+
567
+ context 'constraint returns false' do
568
+ # searchable :unless => proc { false }
569
+ before do
570
+ subject.class.sunspot_options[:unless] = proc { false }
571
+ end
572
+
573
+ it_should_behave_like 'indexed after save'
574
+ end
575
+ end
576
+
577
+ context 'Array' do
578
+ context 'all constraints returns true' do
579
+ # searchable :unless => [:returns_true_1, :returns_true_2]
580
+ before do
581
+ subject.should_receive(:returns_true_1).and_return(true)
582
+ subject.should_receive(:returns_true_2).and_return(true)
583
+ subject.class.sunspot_options[:unless] = [:returns_true_1, 'returns_true_2']
584
+ end
585
+
586
+ it_should_behave_like 'not indexed after save'
587
+ end
588
+
589
+ context 'one constraint returns false' do
590
+ # searchable :unless => [:returns_true, :returns_false]
591
+ before do
592
+ subject.should_receive(:returns_true).and_return(true)
593
+ subject.should_receive(:returns_false).and_return(false)
594
+ subject.class.sunspot_options[:unless] = [:returns_true, 'returns_false']
595
+ end
596
+
597
+ it_should_behave_like 'indexed after save'
598
+ end
599
+ end
600
+ end
601
+ end
@@ -0,0 +1,10 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
+
8
+ # Scrub sensitive parameters from your log
9
+ # filter_parameter_logging :password
10
+ end
@@ -0,0 +1,6 @@
1
+ class PostsController < ApplicationController
2
+ def create
3
+ PostWithAuto.create(params[:post])
4
+ render :nothing => true
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ class Author < ActiveRecord::Base
2
+ self.table_name = :writers
3
+ self.primary_key = :writer_id
4
+
5
+ attr_accessible :name
6
+
7
+ searchable do
8
+ string :name
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ class Blog < ActiveRecord::Base
2
+ has_many :posts
3
+ has_many :comments, :through => :posts
4
+
5
+ attr_accessible :name, :subdomain
6
+
7
+ searchable :include => { :posts => :author } do
8
+ string :subdomain
9
+ text :name
10
+ end
11
+
12
+ # Make sure that includes are added to with multiple searchable calls
13
+ searchable(:include => :comments) {}
14
+ end
@@ -0,0 +1,3 @@
1
+ class Location < ActiveRecord::Base
2
+ attr_accessible :lat, :lng
3
+ end
@@ -0,0 +1,2 @@
1
+ class PhotoPost < PostWithAuto
2
+ end
@@ -0,0 +1,13 @@
1
+ class Post < ActiveRecord::Base
2
+ belongs_to :location
3
+ belongs_to :author
4
+ has_many :comments
5
+
6
+ attr_accessible :title, :type, :location_id, :body, :blog
7
+
8
+ searchable :auto_index => false, :auto_remove => false do
9
+ string :title
10
+ text :body, :more_like_this => true
11
+ location :location
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ class PostWithAuto < ActiveRecord::Base
2
+ def self.table_name
3
+ 'posts'
4
+ end
5
+
6
+ attr_accessible :title, :type, :location_id, :body, :blog
7
+
8
+ searchable :ignore_attribute_changes_of => [ :updated_at ] do
9
+ string :title
10
+ text :body, :more_like_this => true
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class PostWithDefaultScope < ActiveRecord::Base
2
+ def self.table_name
3
+ 'posts'
4
+ end
5
+
6
+ attr_accessible :title, :type, :location_id, :body, :blog
7
+
8
+ default_scope :order => :title
9
+
10
+ searchable :auto_index => false, :auto_remove => false do
11
+ string :title
12
+ end
13
+ end