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
data/Rakefile CHANGED
@@ -1,13 +1,37 @@
1
- # encoding: UTF-8
1
+ desc 'Release Sunspot, Sunspot::Rails and Sunspot::Solr to Gemcutter'
2
+ task :release do
3
+ FileUtils.cp('README.md', 'sunspot/')
2
4
 
3
- require 'rspec/core/rake_task'
5
+ require File.expand_path('../sunspot/lib/sunspot/version', __FILE__)
4
6
 
5
- Dir['tasks/**/*.rake'].each { |t| load t }
7
+ version_tag = "v#{Sunspot::VERSION}"
8
+ system "git tag -am 'Release version #{Sunspot::VERSION}' '#{version_tag}'"
9
+ system "git push origin #{version_tag}:#{version_tag}"
6
10
 
7
- desc "Run all examples"
8
- RSpec::Core::RakeTask.new(:spec) do |t|
9
- t.rspec_opts = '--format documentation'
10
- t.ruby_opts = "-W1"
11
+ FileUtils.cd 'sunspot' do
12
+ system "gem build sunspot.gemspec"
13
+ system "gem push sunspot-#{Sunspot::VERSION}.gem"
14
+ FileUtils.rm "sunspot-#{Sunspot::VERSION}.gem"
15
+ end
16
+
17
+ FileUtils.cd 'sunspot_rails' do
18
+ system "gem build sunspot_rails.gemspec"
19
+ system "gem push sunspot_rails-#{Sunspot::VERSION}.gem"
20
+ FileUtils.rm("sunspot_rails-#{Sunspot::VERSION}.gem")
21
+ end
22
+
23
+ FileUtils.cd 'sunspot_solr' do
24
+ system "gem build sunspot_solr.gemspec"
25
+ system "gem push sunspot_solr-#{Sunspot::VERSION}.gem"
26
+ FileUtils.rm("sunspot_solr-#{Sunspot::VERSION}.gem")
27
+ end
11
28
  end
12
29
 
13
- task :default => :spec
30
+
31
+ desc 'Run all the tests'
32
+ task :default do
33
+ exit system([ "GEM=sunspot ci/travis.sh",
34
+ "GEM=sunspot_rails RAILS=3.0.15 ci/travis.sh",
35
+ "GEM=sunspot_rails RAILS=3.1.6 ci/travis.sh",
36
+ "GEM=sunspot_rails RAILS=3.2.6 ci/travis.sh" ].join(" && ")) ? 0 : 1
37
+ end
data/ci/travis.sh ADDED
@@ -0,0 +1,67 @@
1
+ #!/bin/sh
2
+
3
+ set +e
4
+
5
+ solr_responding() {
6
+ port=$1
7
+ curl -o /dev/null "http://localhost:$port/solr/admin/ping" > /dev/null 2>&1
8
+ }
9
+
10
+ wait_until_solr_responds() {
11
+ port=$1
12
+ while ! solr_responding $1; do
13
+ /bin/echo -n "."
14
+ sleep 1
15
+ done
16
+ }
17
+
18
+ case $GEM in
19
+ "sunspot")
20
+
21
+ cd sunspot
22
+ /bin/echo -n "Starting Solr on port 8983 for Sunspot specs..."
23
+ bundle install --quiet --path vendor/bundle
24
+ if [ -f sunspot-solr.pid ]; then bundle exec sunspot-solr stop || true; fi
25
+
26
+ bundle exec sunspot-solr start -p 8983 -d /tmp/solr
27
+ wait_until_solr_responds 8983
28
+ /bin/echo "done."
29
+
30
+ # Invoke the sunspot specs
31
+ bundle exec rake spec
32
+ rv=$?
33
+
34
+ /bin/echo -n "Stopping Solr... "
35
+ bundle exec sunspot-solr stop
36
+ /bin/echo "done."
37
+
38
+ exit $rv
39
+ ;;
40
+
41
+ "sunspot_rails")
42
+
43
+ cd sunspot
44
+ /bin/echo -n "Starting Solr on port 8983 for Sunspot specs..."
45
+ bundle install --quiet --path vendor/bundle
46
+ if [ -f sunspot-solr.pid ]; then bundle exec sunspot-solr stop || true; fi
47
+
48
+ bundle exec sunspot-solr start -p 8983 -d /tmp/solr
49
+ wait_until_solr_responds 8983
50
+ /bin/echo "done."
51
+
52
+ # Install gems for test Rails application
53
+ cd ../sunspot_rails
54
+ rake spec RAILS=$RAILS
55
+ rv=$?
56
+
57
+ # Cleanup Solr
58
+ /bin/echo -n "Stopping Solr... "
59
+ cd ../sunspot
60
+ bundle exec sunspot-solr stop
61
+ /bin/echo "done."
62
+
63
+ exit $rv
64
+ ;;
65
+
66
+ *)
67
+ esac
@@ -0,0 +1,13 @@
1
+ sunspot-solr.pid
2
+ *.swp
3
+ *.swo
4
+ *~
5
+ coverage
6
+ pkg
7
+ /doc
8
+ .DS_Store
9
+
10
+ .yardoc
11
+ README.rdoc
12
+ .bundle
13
+ Gemfile.lock
File without changes
File without changes
File without changes
data/sunspot/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ Dir['tasks/**/*.rake'].each { |t| load t }
6
+
7
+ desc "Run all examples"
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.rspec_opts = '--format documentation'
10
+ t.ruby_opts = "-W1"
11
+ end
12
+
13
+ task :default => :spec
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  module Sunspot
2
- #
2
+ #
3
3
  # Sunspot works by saving references to the primary key (or natural ID) of
4
4
  # each indexed object, and then retrieving the objects from persistent storage
5
5
  # when their IDs are referenced in search results. In order for Sunspot to
@@ -53,7 +53,7 @@ module Sunspot
53
53
  @instance = instance
54
54
  end
55
55
 
56
- #
56
+ #
57
57
  # The universally-unique ID for this instance that will be stored in solr
58
58
  #
59
59
  # ==== Returns
@@ -149,7 +149,7 @@ module Sunspot
149
149
  end
150
150
  end
151
151
 
152
- # Subclasses of the DataAccessor class take care of retreiving instances of
152
+ # Subclasses of the DataAccessor class take care of retrieving instances of
153
153
  # the adapted class from (usually persistent) storage. Subclasses must
154
154
  # implement the #load method, which takes an id (the value returned by
155
155
  # InstanceAdapter#id, as a string), and returns the instance referenced by
@@ -170,8 +170,13 @@ module Sunspot
170
170
  # Sunspot::Adapters::DataAccessor.register(FileAccessor, File)
171
171
  #
172
172
  class DataAccessor
173
+ # Attributes that should be passed to other adapted subclasses
174
+ attr_accessor :inherited_attributes
175
+ attr_reader :clazz
176
+
173
177
  def initialize(clazz) #:nodoc:
174
178
  @clazz = clazz
179
+ @inherited_attributes = []
175
180
  end
176
181
 
177
182
  # Subclasses can override this class to provide more efficient bulk
@@ -193,7 +198,7 @@ module Sunspot
193
198
  class <<self
194
199
  # Create a DataAccessor for the given class, searching registered
195
200
  # adapters for the best match. See InstanceAdapter#adapt for discussion
196
- # of inheritence.
201
+ # of inheritance.
197
202
  #
198
203
  # ==== Parameters
199
204
  #
@@ -217,7 +222,7 @@ module Sunspot
217
222
  #
218
223
  # data_accessor<Class>:: The data accessor class to register
219
224
  # classes...<Class>::
220
- # One or more classes that this data accessor providess access to
225
+ # One or more classes that this data accessor provides access to
221
226
  #
222
227
  def register(data_accessor, *classes)
223
228
  classes.each do |clazz|
@@ -265,5 +270,80 @@ module Sunspot
265
270
  end
266
271
  end
267
272
  end
273
+
274
+ # Allows to have a registry of the classes adapted by a DataAccessor. This
275
+ # registry does the class registration using DataAccessor's #create and while
276
+ # doing so also allows a registered class to notify which attributes
277
+ # should be inherited by its subclasses.
278
+ # This is useful in cases such us ActiveRecord's #include option, where
279
+ # you may need to run a search in all the subclasses of a searchable model
280
+ # and including some associations for all of them when it loads.
281
+ #
282
+ # ==== Example
283
+ #
284
+ # # ActiveRecordDataAccessor marks :include and :select as inherited_attributes
285
+ # class ActiveRecordDataAccessor < Sunspot::Adapters::DataAccessor
286
+ # # options for the find
287
+ # attr_accessor :include, :select
288
+ #
289
+ # def initialize(clazz)
290
+ # super(clazz)
291
+ # @inherited_attributes = [:include, :select]
292
+ # end
293
+ # end
294
+ #
295
+ # class Event < ActiveRecord::Base
296
+ # searchable do
297
+ # #stuff here
298
+ # end
299
+ # end
300
+ # class Play < Event ; end
301
+ # class Movie < Event ; end
302
+ #
303
+ # # This will push the :include to ALL of the Event's subclasses
304
+ # @search = Event.search(include: [:images])
305
+ #
306
+ # # You can also set the value just one class's attribute
307
+ # @search.data_accessor_for(Play).include = [ :images, :location]
308
+ #
309
+ class Registry
310
+ extend Forwardable
311
+
312
+ def initialize
313
+ @reg = {}
314
+ end
315
+ def_delegator :@reg, :keys, :registered
316
+ def_delegators :@reg, :include?
317
+
318
+ def retrieve(clazz)
319
+ key = clazz.name.to_sym
320
+ if !@reg.include?(key)
321
+ data_accessor = inject_inherited_attributes_for( Adapters::DataAccessor.create(clazz) )
322
+ @reg[key] ||= data_accessor
323
+ end
324
+ @reg[key]
325
+ end
326
+
327
+ # It will inject declared attributes to be inherited from ancestors
328
+ # only if they are not already present in the data_accessor for each class.
329
+ def inject_inherited_attributes_for(data_accessor)
330
+ return data_accessor if @reg.empty?
331
+
332
+ data_accessor.inherited_attributes.each do |attribute|
333
+ if data_accessor.send(attribute).nil? # Inject only if the current class didn't define one.
334
+ inherited_value = nil
335
+ # Now try to find a value for the attribute in the chain of ancestors
336
+ data_accessor.clazz.ancestors.each do |ancestor|
337
+ next if ancestor.name.nil? || ancestor.name.empty?
338
+ key = ancestor.name.to_sym
339
+ inherited_value = @reg[key].send(attribute) if @reg[key]
340
+ break unless inherited_value.nil?
341
+ end
342
+ data_accessor.send("#{attribute.to_s}=", inherited_value) unless inherited_value.nil?
343
+ end
344
+ end
345
+ data_accessor
346
+ end
347
+ end
268
348
  end
269
349
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,8 +1,8 @@
1
1
  module Sunspot
2
2
  module DSL
3
3
  class FieldGroup
4
- def initialize(query, setup, group)
5
- @query, @setup, @group = query, setup, group
4
+ def initialize(setup, group)
5
+ @setup, @group = setup, group
6
6
  end
7
7
 
8
8
  #
@@ -79,7 +79,7 @@ module Sunspot
79
79
 
80
80
  if block
81
81
  Sunspot::Util.instance_eval_or_call(
82
- FieldGroup.new(@query, @setup, group),
82
+ FieldGroup.new(@setup, group),
83
83
  &block
84
84
  )
85
85
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -8,8 +8,6 @@ module Sunspot
8
8
  # allows operations on specific fields.
9
9
  #
10
10
  class Scope
11
- NONE = Object.new
12
-
13
11
  def initialize(scope, setup) #:nodoc:
14
12
  @scope, @setup = scope, setup
15
13
  end
@@ -193,20 +191,19 @@ module Sunspot
193
191
  case args.first
194
192
  when String, Symbol
195
193
  raise ArgumentError if args.length > 2
196
- field_name = args[0]
197
- value = args.length > 1 ? args[1] : NONE
198
- if value == NONE
199
- DSL::Restriction.new(@setup.field(field_name.to_sym), @scope, negated)
200
- else
201
- @scope.add_shorthand_restriction(negated, @setup.field(field_name.to_sym), value)
194
+ field = @setup.field(args[0].to_sym)
195
+ if args.length > 1
196
+ value = args[1]
197
+ @scope.add_shorthand_restriction(negated, field, value)
198
+ else # NONE
199
+ DSL::Restriction.new(field, @scope, negated)
202
200
  end
203
- else
204
- instances = args.flatten
201
+ else # args are instances
205
202
  @scope.add_restriction(
206
203
  negated,
207
204
  IdField.instance,
208
205
  Sunspot::Query::Restriction::AnyOf,
209
- instances.flatten.map { |instance|
206
+ args.flatten.map { |instance|
210
207
  Sunspot::Adapters::InstanceAdapter.adapt(instance).index_id }
211
208
  )
212
209
  end
File without changes
@@ -108,10 +108,9 @@ module Sunspot
108
108
  def with(*args)
109
109
  case args.first
110
110
  when String, Symbol
111
- field_name = args[0]
112
- value = args.length > 1 ? args[1] : Scope::NONE
113
- if value == Scope::NONE
114
- return DSL::RestrictionWithNear.new(@setup.field(field_name.to_sym), @scope, @query, false)
111
+ if args.length == 1 # NONE
112
+ field = @setup.field(args[0].to_sym)
113
+ return DSL::RestrictionWithNear.new(field, @scope, @query, false)
115
114
  end
116
115
  end
117
116
 
File without changes
File without changes
File without changes
File without changes
@@ -30,7 +30,7 @@ module Sunspot
30
30
  params[qualified_param('offset')] = @options[:offset].to_i
31
31
  end
32
32
  if @options[:prefix]
33
- params[qualified_param('prefix')] = escape(@options[:prefix].to_s)
33
+ params[qualified_param('prefix')] = @options[:prefix].to_s
34
34
  end
35
35
  params[qualified_param('mincount')] =
36
36
  case
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -7,6 +7,7 @@ module Sunspot
7
7
  params[qualified_param('range.start')] = @field.to_indexed(@options[:range].first)
8
8
  params[qualified_param('range.end')] = @field.to_indexed(@options[:range].last)
9
9
  params[qualified_param('range.gap')] = "#{@options[:range_interval] || 10}"
10
+ params[qualified_param('range.include')] = @options[:include].to_s if @options[:include]
10
11
  params
11
12
  end
12
13
  end
@@ -144,6 +144,18 @@ module Sunspot
144
144
  end
145
145
  end
146
146
 
147
+ class InRadius < Base
148
+ def initialize(negated, field, lat, lon, radius)
149
+ @lat, @lon, @radius = lat, lon, radius
150
+ super negated, field, [lat, lon, radius]
151
+ end
152
+
153
+ private
154
+ def to_positive_boolean_phrase
155
+ "_query_:\"{!geofilt sfield=#{@field.indexed_name} pt=#{@lat},#{@lon} d=#{@radius}}\""
156
+ end
157
+ end
158
+
147
159
  #
148
160
  # Results must have field with value equal to given value. If the value
149
161
  # is nil, results must have no value for the given field.
File without changes
File without changes
File without changes
File without changes
@@ -208,8 +208,8 @@ module Sunspot
208
208
  "<Sunspot::Search:#{query.to_params.inspect}>"
209
209
  end
210
210
 
211
- def add_field_group(field, options = {}) #:nodoc:
212
- add_group(field.name, FieldGroup.new(field, self, options))
211
+ def add_field_group(field) #:nodoc:
212
+ add_group(field.name, FieldGroup.new(field, self))
213
213
  end
214
214
 
215
215
  def add_field_facet(field, options = {}) #:nodoc:
File without changes
File without changes
File without changes
@@ -0,0 +1,70 @@
1
+ require 'sunspot/search/paginated_collection'
2
+
3
+ module Sunspot
4
+ module Search
5
+ class FieldGroup
6
+ def initialize(field, search) #:nodoc:
7
+ @field, @search = field, search
8
+ end
9
+
10
+ def groups
11
+ @groups ||=
12
+ if solr_response
13
+ paginate_collection(
14
+ solr_response['groups'].map do |group|
15
+ Group.new(group['groupValue'], group['doclist'], @search)
16
+ end
17
+ )
18
+ end
19
+ end
20
+
21
+ def matches
22
+ if solr_response
23
+ solr_response['matches'].to_i
24
+ end
25
+ end
26
+
27
+ def total
28
+ if solr_response
29
+ solr_response['ngroups'].to_i
30
+ end
31
+ end
32
+
33
+ #
34
+ # It populates all grouped hits at once.
35
+ # Useful for eager loading fall grouped results at once.
36
+ #
37
+ def populate_all_hits
38
+ # Init a 2 dimension Hash that contains an array per key
39
+ id_hit_hash = Hash.new { |hash, key| hash[key] = Hash.new{ |h, k| h[k] = [] } }
40
+ groups.each do |g|
41
+ # Take all hits to being populated later on
42
+ g.hits.each do |hit|
43
+ id_hit_hash[hit.class_name][hit.primary_key] |= [hit]
44
+ end
45
+ end
46
+ # Go for each class and load the results' objects into each of the hits
47
+ id_hit_hash.each_pair do |class_name, many_hits|
48
+ ids = many_hits.keys
49
+ data_accessor = @search.data_accessor_for(Util.full_const_get(class_name))
50
+ hits_for_class = id_hit_hash[class_name]
51
+ data_accessor.load_all(ids).each do |result|
52
+ hits = hits_for_class.delete(Adapters::InstanceAdapter.adapt(result).id.to_s)
53
+ hits.each{ |hit| hit.result = result }
54
+ end
55
+ hits_for_class.values.each { |hits| hits.each{|hit| hit.result = nil } }
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def solr_response
62
+ @search.group_response[@field.indexed_name.to_s]
63
+ end
64
+
65
+ def paginate_collection(collection)
66
+ PaginatedCollection.new(collection, @search.query.page, @search.query.per_page, total)
67
+ end
68
+ end
69
+ end
70
+ end
File without changes
File without changes
File without changes
@@ -27,7 +27,7 @@ module Sunspot
27
27
  end
28
28
  id_hit_hash.each_pair do |class_name, hits|
29
29
  ids = hits.map { |id, hit| hit.primary_key }
30
- data_accessor = data_accessor_for(Util.full_const_get(class_name))
30
+ data_accessor = data_accessor_for(Util.full_const_get(class_name))
31
31
  hits_for_class = id_hit_hash[class_name]
32
32
  data_accessor.load_all(ids).each do |result|
33
33
  hit = hits_for_class.delete(Adapters::InstanceAdapter.adapt(result).id.to_s)
@@ -46,9 +46,8 @@ module Sunspot
46
46
  # for more information).
47
47
  #
48
48
  def each_hit_with_result
49
- verified_hits.each do |hit|
50
- yield(hit, hit.result)
51
- end
49
+ return enum_for(:each_hit_with_result) unless block_given?
50
+ verified_hits.each { |hit| yield hit, hit.result }
52
51
  end
53
52
 
54
53
  #
@@ -61,11 +60,8 @@ module Sunspot
61
60
  # the block DSL.
62
61
  #
63
62
  def data_accessor_for(clazz) #:nodoc:
64
- # FIXME: This method does not belong here, but I was getting bogged
65
- # down trying to figure out where it should go. Punted for now.
66
- # - AL 27 Nov 2011
67
- (@data_accessors ||= {})[clazz.name.to_sym] ||=
68
- Adapters::DataAccessor.create(clazz)
63
+ @registry ||= Sunspot::Adapters::Registry.new
64
+ @registry.retrieve(clazz)
69
65
  end
70
66
  end
71
67
  end