acts_as_solr 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/.gitignore +8 -0
  2. data/CHANGE_LOG +233 -0
  3. data/FORKED_CHANGES +3 -0
  4. data/LICENSE +19 -0
  5. data/README.markdown +94 -0
  6. data/README.rdoc +84 -0
  7. data/Rakefile +57 -0
  8. data/TESTING_THE_PLUGIN +25 -0
  9. data/VERSION +1 -0
  10. data/acts_as_solr.gemspec +237 -0
  11. data/config/solr.yml +15 -0
  12. data/config/solr_environment.rb +22 -0
  13. data/init.rb +21 -0
  14. data/install.rb +11 -0
  15. data/lib/acts_as_solr.rb +61 -0
  16. data/lib/acts_methods.rb +284 -0
  17. data/lib/class_methods.rb +239 -0
  18. data/lib/common_methods.rb +89 -0
  19. data/lib/deprecation.rb +61 -0
  20. data/lib/instance_methods.rb +181 -0
  21. data/lib/lazy_document.rb +18 -0
  22. data/lib/parser_methods.rb +230 -0
  23. data/lib/search_results.rb +69 -0
  24. data/lib/solr/connection.rb +191 -0
  25. data/lib/solr/document.rb +78 -0
  26. data/lib/solr/exception.rb +13 -0
  27. data/lib/solr/field.rb +39 -0
  28. data/lib/solr/importer/array_mapper.rb +26 -0
  29. data/lib/solr/importer/delimited_file_source.rb +38 -0
  30. data/lib/solr/importer/hpricot_mapper.rb +27 -0
  31. data/lib/solr/importer/mapper.rb +51 -0
  32. data/lib/solr/importer/solr_source.rb +43 -0
  33. data/lib/solr/importer/xpath_mapper.rb +35 -0
  34. data/lib/solr/importer.rb +19 -0
  35. data/lib/solr/indexer.rb +52 -0
  36. data/lib/solr/request/add_document.rb +63 -0
  37. data/lib/solr/request/base.rb +36 -0
  38. data/lib/solr/request/commit.rb +31 -0
  39. data/lib/solr/request/delete.rb +50 -0
  40. data/lib/solr/request/dismax.rb +46 -0
  41. data/lib/solr/request/index_info.rb +22 -0
  42. data/lib/solr/request/modify_document.rb +51 -0
  43. data/lib/solr/request/optimize.rb +21 -0
  44. data/lib/solr/request/ping.rb +36 -0
  45. data/lib/solr/request/select.rb +56 -0
  46. data/lib/solr/request/spellcheck.rb +30 -0
  47. data/lib/solr/request/standard.rb +402 -0
  48. data/lib/solr/request/update.rb +23 -0
  49. data/lib/solr/request.rb +26 -0
  50. data/lib/solr/response/add_document.rb +17 -0
  51. data/lib/solr/response/base.rb +42 -0
  52. data/lib/solr/response/commit.rb +17 -0
  53. data/lib/solr/response/delete.rb +13 -0
  54. data/lib/solr/response/dismax.rb +8 -0
  55. data/lib/solr/response/index_info.rb +26 -0
  56. data/lib/solr/response/modify_document.rb +17 -0
  57. data/lib/solr/response/optimize.rb +14 -0
  58. data/lib/solr/response/ping.rb +28 -0
  59. data/lib/solr/response/ruby.rb +42 -0
  60. data/lib/solr/response/select.rb +17 -0
  61. data/lib/solr/response/spellcheck.rb +20 -0
  62. data/lib/solr/response/standard.rb +64 -0
  63. data/lib/solr/response/xml.rb +42 -0
  64. data/lib/solr/response.rb +27 -0
  65. data/lib/solr/solrtasks.rb +27 -0
  66. data/lib/solr/util.rb +32 -0
  67. data/lib/solr/xml.rb +44 -0
  68. data/lib/solr.rb +21 -0
  69. data/lib/solr_fixtures.rb +13 -0
  70. data/lib/tasks/database.rake +18 -0
  71. data/lib/tasks/solr.rake +137 -0
  72. data/lib/tasks/test.rake +7 -0
  73. data/lib/will_paginate_support.rb +12 -0
  74. data/solr/CHANGES.txt +1207 -0
  75. data/solr/LICENSE.txt +712 -0
  76. data/solr/NOTICE.txt +90 -0
  77. data/solr/etc/jetty.xml +205 -0
  78. data/solr/etc/webdefault.xml +379 -0
  79. data/solr/lib/easymock.jar +0 -0
  80. data/solr/lib/jetty-6.1.3.jar +0 -0
  81. data/solr/lib/jetty-util-6.1.3.jar +0 -0
  82. data/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
  83. data/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
  84. data/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
  85. data/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
  86. data/solr/lib/servlet-api-2.4.jar +0 -0
  87. data/solr/lib/servlet-api-2.5-6.1.3.jar +0 -0
  88. data/solr/lib/xpp3-1.1.3.4.O.jar +0 -0
  89. data/solr/logs/.empty-dir-for-git +0 -0
  90. data/solr/solr/README.txt +52 -0
  91. data/solr/solr/bin/abc +176 -0
  92. data/solr/solr/bin/abo +176 -0
  93. data/solr/solr/bin/backup +108 -0
  94. data/solr/solr/bin/backupcleaner +142 -0
  95. data/solr/solr/bin/commit +128 -0
  96. data/solr/solr/bin/optimize +129 -0
  97. data/solr/solr/bin/readercycle +129 -0
  98. data/solr/solr/bin/rsyncd-disable +77 -0
  99. data/solr/solr/bin/rsyncd-enable +76 -0
  100. data/solr/solr/bin/rsyncd-start +145 -0
  101. data/solr/solr/bin/rsyncd-stop +105 -0
  102. data/solr/solr/bin/scripts-util +83 -0
  103. data/solr/solr/bin/snapcleaner +148 -0
  104. data/solr/solr/bin/snapinstaller +168 -0
  105. data/solr/solr/bin/snappuller +248 -0
  106. data/solr/solr/bin/snappuller-disable +77 -0
  107. data/solr/solr/bin/snappuller-enable +77 -0
  108. data/solr/solr/bin/snapshooter +109 -0
  109. data/solr/solr/conf/admin-extra.html +31 -0
  110. data/solr/solr/conf/protwords.txt +21 -0
  111. data/solr/solr/conf/schema.xml +126 -0
  112. data/solr/solr/conf/scripts.conf +24 -0
  113. data/solr/solr/conf/solrconfig.xml +458 -0
  114. data/solr/solr/conf/stopwords.txt +57 -0
  115. data/solr/solr/conf/synonyms.txt +31 -0
  116. data/solr/solr/conf/xslt/example.xsl +132 -0
  117. data/solr/solr/conf/xslt/example_atom.xsl +63 -0
  118. data/solr/solr/conf/xslt/example_rss.xsl +62 -0
  119. data/solr/start.jar +0 -0
  120. data/solr/tmp/.empty-dir-for-git +0 -0
  121. data/solr/webapps/solr.war +0 -0
  122. data/test/config/solr.yml +2 -0
  123. data/test/db/connections/mysql/connection.rb +10 -0
  124. data/test/db/connections/sqlite/connection.rb +8 -0
  125. data/test/db/migrate/001_create_books.rb +15 -0
  126. data/test/db/migrate/002_create_movies.rb +12 -0
  127. data/test/db/migrate/003_create_categories.rb +11 -0
  128. data/test/db/migrate/004_create_electronics.rb +16 -0
  129. data/test/db/migrate/005_create_authors.rb +12 -0
  130. data/test/db/migrate/006_create_postings.rb +9 -0
  131. data/test/db/migrate/007_create_posts.rb +13 -0
  132. data/test/db/migrate/008_create_gadgets.rb +11 -0
  133. data/test/fixtures/authors.yml +9 -0
  134. data/test/fixtures/books.yml +13 -0
  135. data/test/fixtures/categories.yml +7 -0
  136. data/test/fixtures/db_definitions/mysql.sql +41 -0
  137. data/test/fixtures/electronics.yml +49 -0
  138. data/test/fixtures/movies.yml +9 -0
  139. data/test/fixtures/postings.yml +10 -0
  140. data/test/functional/acts_as_solr_test.rb +413 -0
  141. data/test/functional/association_indexing_test.rb +37 -0
  142. data/test/functional/faceted_search_test.rb +163 -0
  143. data/test/functional/multi_solr_search_test.rb +51 -0
  144. data/test/models/author.rb +10 -0
  145. data/test/models/book.rb +10 -0
  146. data/test/models/category.rb +8 -0
  147. data/test/models/electronic.rb +21 -0
  148. data/test/models/gadget.rb +9 -0
  149. data/test/models/movie.rb +17 -0
  150. data/test/models/novel.rb +2 -0
  151. data/test/models/post.rb +3 -0
  152. data/test/models/posting.rb +11 -0
  153. data/test/test_helper.rb +51 -0
  154. data/test/unit/acts_methods_shoulda.rb +70 -0
  155. data/test/unit/class_methods_shoulda.rb +90 -0
  156. data/test/unit/common_methods_shoulda.rb +112 -0
  157. data/test/unit/instance_methods_shoulda.rb +326 -0
  158. data/test/unit/lazy_document_shoulda.rb +35 -0
  159. data/test/unit/parser_instance.rb +19 -0
  160. data/test/unit/parser_methods_shoulda.rb +279 -0
  161. data/test/unit/solr_instance.rb +46 -0
  162. data/test/unit/test_helper.rb +26 -0
  163. metadata +259 -0
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.log
2
+ *.log
3
+ *_pid
4
+ coverage/*
5
+ coverage.data
6
+ solr/solr/data/*
7
+ .svn
8
+ test/db/*.db
data/CHANGE_LOG ADDED
@@ -0,0 +1,233 @@
1
+ == CHANGE_LOG
2
+ === Development
3
+ <b>NEW</b>:: A unit test suite based on Shoulda, not requiring a running Solr or a Rails environment. (Mathias Meyer)
4
+ <b>NEW</b>:: Added the :offline option to the acts_as_solr method. (Mathias Meyer)
5
+ <b>NEW</b>:: Added :lazy flag to find_by_solr, and with that support to load records lazily. (Mathias Meyer)
6
+ <b>FIX</b>:: Added test: to solr.yml so you don't need to do this by hand. (Ken Harris)
7
+ <b>FIX</b>:: Updated bundled Solr to 1.3. (Mathias Meyer)
8
+ <b>FIX</b>:: Updated bundled solr-ruby to 0.0.6 which comes bundled with Solr 1.3. (Mathias Meyer)
9
+ <b>FIX</b>:: Improved logging of the reindex rake task. (David Stevenson)
10
+ <b>FIX</b>:: Added requirement for libxml-ruby > 0.7, if libxml-ruby is installed. (David Stevenson)
11
+ <b>FIX</b>:: Ruby 1.9 compatibility fixes. (David Palm)
12
+ <b>FIX</b>:: Fixed compatibility with Desert by renaming environment.rb to solr_environment.rb. (David Stevenson)
13
+ <b>FIX</b>:: Moved the require of solr_environment only into tasks that need it. (David Stevenson)
14
+ <b>NEW</b>:: Added support to alias fields and includes using the option :as for acts_as_solr. See the RDoc for details. (Nick Hengeveld)
15
+ <b>NEW</b>:: Added support to attach the score to multi search results. (Mathias Meyer)
16
+ <b>NEW</b>:: Added support for facets on date fields. (Curtis Hatter)
17
+
18
+ === 06-18-2007: Version 0.9
19
+ <b>NEW</b>:: Added the option :scores when doing a search. If set to true this will return the score as a 'solr_score' attribute or each one of the instances found
20
+ books = Book.find_by_solr 'ruby OR splinter', :scores => true
21
+ books.records.first.solr_score
22
+ => 1.21321397
23
+ books.records.last.solr_score
24
+ => 0.12321548
25
+
26
+ <b>NEW</b>:: Major change on the way the results returned are accessed.
27
+ books = Book.find_by_solr 'ruby'
28
+ # the above will return a SearchResults class with 4 methods:
29
+ # docs|results|records: will return an array of records found
30
+ #
31
+ # books.records.is_a?(Array)
32
+ # => true
33
+ #
34
+ # total|num_found|total_hits: will return the total number of records found
35
+ #
36
+ # books.total
37
+ # => 2
38
+ #
39
+ # facets: will return the facets when doing a faceted search
40
+ #
41
+ # max_score|highest_score: returns the highest score found
42
+ #
43
+ # books.max_score
44
+ # => 1.3213213
45
+
46
+ <b>NEW</b>:: Integrating acts_as_solr to use solr-ruby as the 'backend'. Integration based on the patch submitted by Erik Hatcher
47
+ <b>NEW</b>:: Re-factoring rebuild_solr_index to allow adds to be done in batch; and if a finder block is given, it will be called to retrieve the items to index. (thanks Daniel E.)
48
+ <b>NEW</b>:: Adding the option to specify the port Solr should start when using rake solr:start
49
+ rake solr:start RAILS_ENV=your_env PORT=XX
50
+
51
+ <b>NEW</b>:: Adding deprecation warning for the :background configuration option. It will no longer be updated.
52
+ <b>NEW</b>:: Adding support for models that use a primary key other than integer
53
+ class Posting < ActiveRecord::Base
54
+ set_primary_key 'guid' #string
55
+ #make sure you set the :primary_key_field => 'pk_s' if you wish to use a string field as the primary key
56
+ acts_as_solr({},{:primary_key_field => 'pk_s'})
57
+ end
58
+
59
+ <b>FIX</b>:: Disabling of storing most fields. Storage isn't useful for acts_as_solr in any field other than the pk and id fields. It just takes up space and time. (thanks Daniel E.)
60
+ <b>FIX</b>:: Re-factoring code submitted by Daniel E.
61
+ <b>NEW</b>:: Adding an :auto_commit option that will only send the commit command to Solr if it is set to true
62
+ class Author < ActiveRecord::Base
63
+ acts_as_solr :auto_commit => false
64
+ end
65
+
66
+ <b>FIX</b>:: Fixing bug on rake's test task
67
+ <b>FIX</b>:: Making acts_as_solr's Post class compatible with Solr 1.2 (thanks Si)
68
+ <b>NEW</b>:: Adding Solr 1.2
69
+ <b>FIX</b>:: Removing Solr 1.1
70
+ <b>NEW</b>:: Adding a conditional :if option to the acts_as_solr call. It behaves the same way ActiveRecord's :if argument option does.
71
+ class Electronic < ActiveRecord::Base
72
+ acts_as_solr :if => proc{|record| record.is_active?}
73
+ end
74
+
75
+ <b>NEW</b>:: Adding fixtures to Solr index when using rake db:fixtures:load
76
+ <b>FIX</b>:: Fixing boost warning messages
77
+ <b>FIX</b>:: Fixing bug when adding a facet to a field that contains boost
78
+ <b>NEW</b>:: Deprecating find_with_facet and combining functionality with find_by_solr
79
+ <b>NEW</b>:: Adding the option to :exclude_fields when indexing a model
80
+ class User < ActiveRecord::Base
81
+ acts_as_solr :exclude_fields => [:password, :login, :credit_card_number]
82
+ end
83
+
84
+ <b>FIX</b>:: Fixing branch bug on older ruby version
85
+ <b>NEW</b>:: Adding boost support for fields and documents being indexed:
86
+ class Electronic < ActiveRecord::Base
87
+ # You can add boosting on a per-field basis or on the entire document
88
+ acts_as_solr :fields => [{:price => {:boost => 5.0}}], :boost => 5.0
89
+ end
90
+
91
+ <b>FIX</b>:: Fixed the acts_as_solr limitation to only accept test|development|production environments.
92
+
93
+ === 05-16-2007: Version 0.8.5
94
+ <b>FIX</b>:: There's no need to specify the :field_types anymore when doing a search in a model that specifies a field type for a field.
95
+ <b>FIX</b>:: Better handling of nil values from indexed fields. Solr complained when indexing fields with field type and the field values being passed as nils.
96
+ <b>NEW</b>:: Adding Solr sort (order by) option to the search query (thanks Kevin Hunt)
97
+ <b>FIX</b>:: Applying patch suggested for increasing the Solr commit speed (thanks Mourad Hammiche)
98
+ <b>FIX</b>:: Updated documentation
99
+
100
+ === 05-10-2007: Version 0.8
101
+ <b>NEW</b>: New video tutorial
102
+ <b>NEW</b>: Faceted search has been implemented and its possible to 'drill-down' on the facets
103
+ <b>NEW</b>: New rake tasks you can use to start/stop the solr server in test, development and production environments: (thanks Matt Clark)
104
+ rake solr:start|stop RAILS_ENV=test|development|production (defaults to development if none given)
105
+
106
+ <b>NEW</b>: Changes to the plugin's test framework and it now supports Sqlite as well (thanks Matt Clark)
107
+ <b>FIX</b>: Patch applied (thanks Micah) that allows one to have multiple solr instances in the same servlet
108
+ <b>FIX</b>: Patch applied (thanks Micah) that allows indexing of STIs
109
+ <b>FIX</b>: Patch applied (thanks Gordon) that allows the plugin to use a table's primary key different than 'id'
110
+ <b>FIX</b>: Returning empty array instead of empty strings when no records are found
111
+ <b>FIX</b>: Problem with unit tests failing due to order of the tests and speed of the commits
112
+
113
+ === 02-16-2007: Version 0.7
114
+ <b>NEW</b>: You can now specify the field types when indexing and searching if
115
+ you'd like to preserve its original type:
116
+
117
+ <b>Indexing</b>
118
+
119
+ Each field passed can also be a hash with the value being a field type
120
+
121
+ class Electronic < ActiveRecord::Base
122
+ acts_as_solr :fields => [{:price => :range_float}, {:current_time => :date}]
123
+ def current_time
124
+ Time.now
125
+ end
126
+ end
127
+
128
+ <b>Searching</b>
129
+ Electronic.find_by_solr "ipod AND price:[* TO 59.99]",
130
+ :field_types => [{:price => :range_float}]
131
+
132
+ The field types accepted are:
133
+ <em>:float</em>:: Index the field value as a float (ie.: 12.87)
134
+ <em>:integer</em>:: Index the field value as an integer (ie.: 31)
135
+ <em>:boolean</em>:: Index the field value as a boolean (ie.: true/false)
136
+ <em>:date</em>:: Index the field value as a date (ie.: Wed Nov 15 23:13:03 PST 2006)
137
+ <em>:string</em>:: Index the field value as a text string, not applying the same indexing filters as a regular text field
138
+ <em>:range_integer</em>:: Index the field value for integer range queries (ie.:[5 TO 20])
139
+ <em>:range_float</em>:: Index the field value for float range queries (ie.:[14.56 TO 19.99])
140
+
141
+ <b>Setting the field type preserves its original type when indexed</b>
142
+
143
+ <b>FIX</b>: Fixing sorting bug. Thanks for the catch Laurel
144
+
145
+ <b>FIX</b>: Fixing small bug when installing the plugin
146
+
147
+ <b>NEW</b>: Adding the :additional_fields option to the acts_as_solr method
148
+
149
+ === 02-05-2007: Version 0.6.5
150
+ <b>NEW</b>:: Added multi-model search, which can be used to execute a search across multiple models:
151
+ Book.multi_solr_search "Napoleon OR Tom", :models => [Movie]
152
+
153
+ ====options:
154
+ Accepts the same options as find_by_solr plus:
155
+ models:: The additional models you'd like to include in the search
156
+ results_format:: Specify the format of the results found
157
+ :objects :: Will return an array with the results being objects (default). Example:
158
+ Book.multi_solr_search "Napoleon OR Tom", :models => [Movie], :results_format => :objects
159
+ :ids :: Will return an array with the ids of each entry found. Example:
160
+ Book.multi_solr_search "Napoleon OR Tom", :models => [Movie], :results_format => :ids
161
+ => [{"id" => "Movie:1"},{"id" => Book:1}]
162
+ Where the value of each array is as Model:instance_id
163
+
164
+ === 02-03-2007: Version 0.6
165
+ <b>NEW</b>:: Added basic faceted search functionality for indexing and searching:
166
+
167
+ ==== Indexing:
168
+
169
+ class Electronic < ActiveRecord::Base
170
+ acts_as_solr :facets => [:category, :manufacturer]
171
+ end
172
+
173
+ ==== Searching:
174
+
175
+ Electronic.find_with_facet "memory", :facets => {:fields =>[:category]}
176
+
177
+ === 01-15-2007: Version 0.5
178
+ <b>NEW</b>:: Added model association indexing, which means you can include any :has_one, :has_many,
179
+ :belongs_to and :has_and_belongs_to_many association to be indexed:
180
+
181
+ class Category < ActiveRecord::Base
182
+ has_many :books
183
+ acts_as_solr :include => [:books]
184
+ end
185
+
186
+ class Book < ActiveRecord::Base
187
+ belongs_to :category
188
+ acts_as_solr :include => [:category]
189
+ end
190
+
191
+ === 01-11-2007:
192
+ <b>NEW</b>:: Added the acts_as_solr's plugin tests
193
+
194
+ === 11-07-2006: Version 0.4
195
+ <b>NEW</b>:: Added :background option, which takes and integer value (in minutes) to wait before committing the changes to Solr. This depends on rail_cron being installed. By setting up the background job we prevent the users from having to wait for Solr records to be created, and we keep from updating the index over and over for quickly successive changes. (Rob Kaufman)
196
+
197
+ === 11-02-2006: Version 0.3
198
+ <b>NEW</b>:: Added a method (Model.count_by_solr) that returns the total number of documents found based on query passed
199
+ <b>NEW</b>:: Added configuration for production and development environments
200
+
201
+ === 10-21-2006: Version 0.2
202
+ <b>PLUGIN</b>
203
+ <b>FIX</b>:: Fixed bug when mixing search-by-field and 'free' search: Model.find_by_solr 'solr AND name:Thiago'
204
+ <b>FIX</b>:: Fixed bug with multi-terms search: Book.find_by_solr 'anteater john'
205
+ <b>FIX</b>:: Fixed bug when including more than one search field: Model.find_by_solr 'name:Thiago AND engine:Solr'
206
+ <b>FIX</b>:: Fixed bug when rebuilding the index, it wasn't saving the data
207
+ <b>NEW</b>:: Added the ability to index custom methods from a model as search fields
208
+ <b>NEW</b>:: Added a search method (Model.find_id_by_solr) that will return only the id of the results
209
+
210
+ <b>SCHEMA.XML</b>
211
+ <b>NEW</b>:: Added a new field: <field name="default" type="text" indexed="true" stored="true" />
212
+ <b>NEW</b>:: Added a default search field: <defaultSearchField>default</defaultSearchField>
213
+ <b>FIX</b>:: Changed the defaultOperator to AND instead of OR
214
+
215
+ === 09-29-2006: Version 0.1
216
+ <b>PLUGIN</b>
217
+ <b>NEW</b>:: Included the option of having a Solr config file inside the rails env.
218
+ <b>NEW</b>:: Added the ability of indexing only certain fields, if you chose to.
219
+ <b>NEW</b>:: Added configuration options
220
+ <b>NEW</b>:: Changed the way the search was done:
221
+ Old: You were forced the specify the field you wanted to look for
222
+ ('field:value') and you had to specify a default search field as
223
+ well, for when you didn't include the 'field' in the search term
224
+ New: The new search features include:
225
+ - You don't have to specify a default search field;
226
+ - You are not forced to include the field name in the search term,
227
+ unless you choose to search for a specific field ('name:Thiago');
228
+ - You can pass the starting row and the number of rows per page,
229
+ which is usefull for pagination
230
+ <b>NEW</b>:: Included a method to rebuild the index files
231
+
232
+ <b>SCHEMA.XML</b>
233
+ <b>NEW</b>:: Created an optimized version of the config file to better work with this plugin
data/FORKED_CHANGES ADDED
@@ -0,0 +1,3 @@
1
+ - highlighting support (needs doc)
2
+ - invalid chars in XML bug fix
3
+ - Raise a specific Exception class on connection error
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2006 Erik Hatcher, Thiago Jackiw
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,94 @@
1
+ `acts_as_solr` Rails plugin
2
+ ======
3
+ This plugin adds full text search capabilities and many other nifty features from Apache's [Solr](http://lucene.apache.org/solr/) to any Rails model.
4
+ It was based on the first draft by Erik Hatcher.
5
+
6
+ Current Release
7
+ ======
8
+ The current stable release is v0.9 and was released on 06-18-2007.
9
+
10
+ Changes
11
+ ======
12
+ Please refer to the CHANGE_LOG
13
+
14
+ Installation
15
+ ======
16
+
17
+ For Rails >= 2.1:
18
+
19
+ script/plugin install git://github.com/mattmatt/acts_as_solr.git
20
+
21
+ For Rails < 2.1:
22
+
23
+ cd vendor/plugins
24
+ git clone git://github.com/mattmatt/acts_as_solr.git
25
+ rm -rf acts_as_solr/.git
26
+
27
+ Make sure you copy `vendor/plugins/acts_as_solr/config/solr.yml` to your Rails
28
+ application's config directory, when you install via `git clone`.
29
+
30
+ Requirements
31
+ ------
32
+ * Java Runtime Environment(JRE) 1.5 aka 5.0 [http://www.java.com/en/download/index.jsp](http://www.java.com/en/download/index.jsp)
33
+ * If you have libxml-ruby installed, make sure it's at least version 0.7
34
+
35
+ Configuration
36
+ ======
37
+ Basically everything is configured to work out of the box. You can use `rake solr:start` and `rake solr:stop`
38
+ to start and stop the Solr web server (an embedded Jetty). If the default JVM options aren't suitable for
39
+ your environment, you can configure them in solr.yml with the option `jvm_options`. There is a default
40
+ set for the production environment to have some more memory available for the JVM than the defaults, but
41
+ feel free to change them to your liking.
42
+
43
+ Basic Usage
44
+ ======
45
+ <pre><code>
46
+ # Just include the line below to any of your ActiveRecord models:
47
+ acts_as_solr
48
+
49
+ # Or if you want, you can specify only the fields that should be indexed:
50
+ acts_as_solr :fields => [:name, :author]
51
+
52
+ # Then to find instances of your model, just do:
53
+ Model.find_by_solr(query) #query is a string representing your query
54
+
55
+ # Please see ActsAsSolr::ActsMethods for a complete info
56
+
57
+ </code></pre>
58
+
59
+
60
+ `acts_as_solr` in your tests
61
+ ======
62
+ To test code that uses `acts_as_solr` you must start a Solr server for the test environment. You can do that with `rake solr:start RAILS_ENV=test`
63
+
64
+ However, if you would like to mock out Solr calls so that a Solr server is not needed (and your tests will run much faster), just add this to your `test_helper.rb` or similar:
65
+
66
+ <pre><code>
67
+ class ActsAsSolr::Post
68
+ def self.execute(request)
69
+ true
70
+ end
71
+ end
72
+ </pre></code>
73
+
74
+ ([via](http://www.subelsky.com/2007/10/actsassolr-capistranhttpwwwbloggercomim.html#c1646308013209805416))
75
+
76
+ Authors
77
+ ======
78
+ Erik Hatcher: First draft<br>
79
+ Thiago Jackiw: Previous developer<br>
80
+ Luke Francl: Current developer<br>
81
+ Mathias Meyer: Current developer<br>
82
+
83
+ Support
84
+ =======
85
+
86
+ Check the [project website](http://mattmatt.github.com/acts_as_solr) or stop by the [Google Group](http://groups.google.com/group/acts_as_solr). Send bug reports through [GitHub Issues](http://github.com/mattmatt/acts_as_solr/issues).
87
+
88
+ Release Information
89
+ ======
90
+ Released under the MIT license.
91
+
92
+ More info
93
+ ======
94
+ The old [acts_as_solr homepage](http://acts-as-solr.railsfreaks.com) is no more. For more up-to-date information, check out the project page of the current mainline on [GitHub](http://github.com/mattmatt/acts_as_solr/wikis).
data/README.rdoc ADDED
@@ -0,0 +1,84 @@
1
+ = acts_as_solr Rails plugin
2
+
3
+ This plugin adds full text search capabilities and many other nifty features from Apache's Solr[http://lucene.apache.org/solr/] to any Rails model.
4
+ It was based on the first draft by Erik Hatcher.
5
+
6
+ == Current Release
7
+
8
+ There is no numbered release yet, but the master branch is always considered stable.
9
+
10
+ == Support
11
+
12
+ Check the project website[http://mattmatt.github.com/acts_as_solr] or stop by the Google Group[http://groups.google.com/group/acts_as_solr]. Send bug reports through GitHub[http://github.com/mattmatt/acts_as_solr/issues].
13
+
14
+ == Changes
15
+
16
+ Please refer to the CHANGELOG[http://github.com/mattmatt/acts_as_solr/blob/master/CHANGE_LOG]
17
+
18
+ == Installation
19
+
20
+ For Rails >= 2.1:
21
+
22
+ script/plugin install git://github.com/mattmatt/acts_as_solr.git
23
+
24
+ For Rails < 2.1:
25
+
26
+ cd vendor/plugins
27
+ git clone git://github.com/mattmatt/acts_as_solr.git
28
+ rm -rf acts_as_solr/.git
29
+
30
+ Make sure you copy vendor/plugins/acts_as_solr/config/solr.yml to your Rails
31
+ application's config directory, when you install via git clone.
32
+
33
+ == Requirements
34
+
35
+ * Java Runtime Environment(JRE) 1.5 aka 5.0 [http://www.java.com/en/download/index.jsp](http://www.java.com/en/download/index.jsp)
36
+ * If you have libxml-ruby installed, make sure it's at least version 0.7
37
+
38
+ == Configuration
39
+
40
+ Basically everything is configured to work out of the box. You can use `rake solr:start` and `rake solr:stop`
41
+ to start and stop the Solr web server (an embedded Jetty). If the default JVM options aren't suitable for
42
+ your environment, you can configure them in solr.yml with the option `jvm_options`. There is a default
43
+ set for the production environment to have some more memory available for the JVM than the defaults, but
44
+ feel free to change them to your liking.
45
+
46
+ == Basic Usage
47
+
48
+ # Just include the line below to any of your ActiveRecord models:
49
+ acts_as_solr
50
+
51
+ # Or if you want, you can specify only the fields that should be indexed:
52
+ acts_as_solr :fields => [:name, :author]
53
+
54
+ # Then to find instances of your model, just do:
55
+ Model.find_by_solr(query) #query is a string representing your query
56
+
57
+ # Please see ActsAsSolr::ActsMethods for a complete info
58
+
59
+ == acts_as_solr in your tests
60
+
61
+ To test code that uses acts_as_solr you must start a Solr server for the test environment. You can do that with
62
+
63
+ rake solr:start RAILS_ENV=test
64
+
65
+ However, if you would like to mock out Solr calls so that a Solr server is not needed (and your tests will run much faster), just add this to your `test_helper.rb` or similar:
66
+
67
+ class ActsAsSolr::Post
68
+ def self.execute(request)
69
+ true
70
+ end
71
+ end
72
+
73
+ (via[http://www.subelsky.com/2007/10/actsassolr-capistranhttpwwwbloggercomim.html#c1646308013209805416])
74
+
75
+ == Authors
76
+
77
+ Erik Hatcher: First draft
78
+ Thiago Jackiw: Previous developer
79
+ Luke Francl: Current developer
80
+ Mathias Meyer: Current developer
81
+
82
+ == Release Information
83
+
84
+ Released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "acts_as_solr"
8
+ gem.summary = "Solr integration for rails"
9
+ gem.description = "Acts As Solr"
10
+ gem.email = "kyle@onemorecloud.com"
11
+ gem.homepage = "http://github.com/onemorecloud/acts_as_solr"
12
+ gem.authors = ["Kyle Maxwell"]
13
+ gem.add_development_dependency "thoughtbot-shoulda"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/*_test.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/*_test.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ if File.exist?('VERSION')
48
+ version = File.read('VERSION')
49
+ else
50
+ version = ""
51
+ end
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "robots #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
@@ -0,0 +1,25 @@
1
+ acts_as_solr comes with a quick and fast unit test suite, and with a longer-running
2
+ functional test suite, the latter testing the actual integration with Solr.
3
+
4
+ The unit test suite is written using Shoulda, so make sure you have a recent version
5
+ installed.
6
+
7
+ Running `rake test` or just `rake` will run both test suites. Use `rake test:unit` to
8
+ just run the unit test suite.
9
+
10
+ == How to run functional tests for this plugin:
11
+ To run the acts_as_solr's plugin tests run the following steps:
12
+
13
+ - create a MySQL database called "actsassolr_test" (if you want to use MySQL)
14
+
15
+ - create a new Rails project, if needed (the plugin can only be tested from within a Rails project); move/checkout acts_as_solr into its vendor/plugins/, as usual
16
+
17
+ - copy vendor/plugins/acts_as_solr/config/solr.yml to config/ (the Rails config folder)
18
+
19
+ - rake solr:start RAILS_ENV=test
20
+
21
+ - rake test:functional (Accepts the following arguments: DB=sqlite|mysql and MYSQL_USER=user)
22
+
23
+ == Troubleshooting:
24
+ If for some reason the tests don't run and you get MySQL errors, make sure you edit the MYSQL_USER entry under
25
+ config/environment.rb. It's recommended to create or use a MySQL user with no password.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0