honkster-acts_as_solr 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGE_LOG +233 -0
- data/LICENSE +19 -0
- data/README.markdown +118 -0
- data/README.rdoc +107 -0
- data/Rakefile +68 -0
- data/TESTING_THE_PLUGIN +25 -0
- data/VERSION +1 -0
- data/lib/acts_as_solr/acts_methods.rb +279 -0
- data/lib/acts_as_solr/class_methods.rb +236 -0
- data/lib/acts_as_solr/common_methods.rb +89 -0
- data/lib/acts_as_solr/deprecation.rb +61 -0
- data/lib/acts_as_solr/instance_methods.rb +166 -0
- data/lib/acts_as_solr/lazy_document.rb +18 -0
- data/lib/acts_as_solr/parser_methods.rb +201 -0
- data/lib/acts_as_solr/search_results.rb +68 -0
- data/lib/acts_as_solr/solr_fixtures.rb +13 -0
- data/lib/acts_as_solr/tasks/database.rake +16 -0
- data/lib/acts_as_solr/tasks/solr.rake +132 -0
- data/lib/acts_as_solr/tasks/test.rake +5 -0
- data/lib/acts_as_solr/tasks.rb +10 -0
- data/lib/acts_as_solr.rb +64 -0
- data/lib/solr/connection.rb +177 -0
- data/lib/solr/document.rb +75 -0
- data/lib/solr/exception.rb +13 -0
- data/lib/solr/field.rb +36 -0
- data/lib/solr/importer/array_mapper.rb +26 -0
- data/lib/solr/importer/delimited_file_source.rb +38 -0
- data/lib/solr/importer/hpricot_mapper.rb +27 -0
- data/lib/solr/importer/mapper.rb +51 -0
- data/lib/solr/importer/solr_source.rb +41 -0
- data/lib/solr/importer/xpath_mapper.rb +35 -0
- data/lib/solr/importer.rb +19 -0
- data/lib/solr/indexer.rb +52 -0
- data/lib/solr/request/add_document.rb +58 -0
- data/lib/solr/request/base.rb +36 -0
- data/lib/solr/request/commit.rb +29 -0
- data/lib/solr/request/delete.rb +48 -0
- data/lib/solr/request/dismax.rb +46 -0
- data/lib/solr/request/index_info.rb +22 -0
- data/lib/solr/request/modify_document.rb +46 -0
- data/lib/solr/request/optimize.rb +19 -0
- data/lib/solr/request/ping.rb +36 -0
- data/lib/solr/request/select.rb +54 -0
- data/lib/solr/request/spellcheck.rb +30 -0
- data/lib/solr/request/standard.rb +402 -0
- data/lib/solr/request/update.rb +23 -0
- data/lib/solr/request.rb +26 -0
- data/lib/solr/response/add_document.rb +17 -0
- data/lib/solr/response/base.rb +42 -0
- data/lib/solr/response/commit.rb +15 -0
- data/lib/solr/response/delete.rb +13 -0
- data/lib/solr/response/dismax.rb +8 -0
- data/lib/solr/response/index_info.rb +26 -0
- data/lib/solr/response/modify_document.rb +17 -0
- data/lib/solr/response/optimize.rb +14 -0
- data/lib/solr/response/ping.rb +26 -0
- data/lib/solr/response/ruby.rb +42 -0
- data/lib/solr/response/select.rb +17 -0
- data/lib/solr/response/spellcheck.rb +20 -0
- data/lib/solr/response/standard.rb +60 -0
- data/lib/solr/response/xml.rb +39 -0
- data/lib/solr/response.rb +27 -0
- data/lib/solr/solrtasks.rb +27 -0
- data/lib/solr/util.rb +32 -0
- data/lib/solr/xml.rb +44 -0
- data/lib/solr.rb +26 -0
- data/solr/CHANGES.txt +1207 -0
- data/solr/LICENSE.txt +712 -0
- data/solr/NOTICE.txt +90 -0
- data/solr/etc/jetty.xml +205 -0
- data/solr/etc/webdefault.xml +379 -0
- data/solr/lib/easymock.jar +0 -0
- data/solr/lib/jetty-6.1.3.jar +0 -0
- data/solr/lib/jetty-util-6.1.3.jar +0 -0
- data/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
- data/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
- data/solr/lib/servlet-api-2.4.jar +0 -0
- data/solr/lib/servlet-api-2.5-6.1.3.jar +0 -0
- data/solr/lib/xpp3-1.1.3.4.O.jar +0 -0
- data/solr/solr/README.txt +52 -0
- data/solr/solr/bin/abc +176 -0
- data/solr/solr/bin/abo +176 -0
- data/solr/solr/bin/backup +108 -0
- data/solr/solr/bin/backupcleaner +142 -0
- data/solr/solr/bin/commit +128 -0
- data/solr/solr/bin/optimize +129 -0
- data/solr/solr/bin/readercycle +129 -0
- data/solr/solr/bin/rsyncd-disable +77 -0
- data/solr/solr/bin/rsyncd-enable +76 -0
- data/solr/solr/bin/rsyncd-start +145 -0
- data/solr/solr/bin/rsyncd-stop +105 -0
- data/solr/solr/bin/scripts-util +83 -0
- data/solr/solr/bin/snapcleaner +148 -0
- data/solr/solr/bin/snapinstaller +168 -0
- data/solr/solr/bin/snappuller +248 -0
- data/solr/solr/bin/snappuller-disable +77 -0
- data/solr/solr/bin/snappuller-enable +77 -0
- data/solr/solr/bin/snapshooter +109 -0
- data/solr/solr/conf/admin-extra.html +31 -0
- data/solr/solr/conf/protwords.txt +21 -0
- data/solr/solr/conf/schema.xml +126 -0
- data/solr/solr/conf/scripts.conf +24 -0
- data/solr/solr/conf/solrconfig.xml +458 -0
- data/solr/solr/conf/stopwords.txt +57 -0
- data/solr/solr/conf/synonyms.txt +31 -0
- data/solr/solr/conf/xslt/example.xsl +132 -0
- data/solr/solr/conf/xslt/example_atom.xsl +63 -0
- data/solr/solr/conf/xslt/example_rss.xsl +62 -0
- data/solr/start.jar +0 -0
- data/solr/webapps/solr.war +0 -0
- data/test/config/solr.yml +2 -0
- data/test/db/connections/mysql/connection.rb +10 -0
- data/test/db/connections/sqlite/connection.rb +8 -0
- data/test/db/migrate/001_create_books.rb +15 -0
- data/test/db/migrate/002_create_movies.rb +12 -0
- data/test/db/migrate/003_create_categories.rb +11 -0
- data/test/db/migrate/004_create_electronics.rb +16 -0
- data/test/db/migrate/005_create_authors.rb +12 -0
- data/test/db/migrate/006_create_postings.rb +9 -0
- data/test/db/migrate/007_create_posts.rb +13 -0
- data/test/db/migrate/008_create_gadgets.rb +11 -0
- data/test/fixtures/authors.yml +9 -0
- data/test/fixtures/books.yml +13 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/db_definitions/mysql.sql +41 -0
- data/test/fixtures/electronics.yml +49 -0
- data/test/fixtures/movies.yml +9 -0
- data/test/fixtures/postings.yml +10 -0
- data/test/functional/acts_as_solr_test.rb +413 -0
- data/test/functional/association_indexing_test.rb +37 -0
- data/test/functional/faceted_search_test.rb +163 -0
- data/test/functional/multi_solr_search_test.rb +51 -0
- data/test/models/author.rb +10 -0
- data/test/models/book.rb +10 -0
- data/test/models/category.rb +8 -0
- data/test/models/electronic.rb +21 -0
- data/test/models/gadget.rb +9 -0
- data/test/models/movie.rb +17 -0
- data/test/models/novel.rb +2 -0
- data/test/models/post.rb +3 -0
- data/test/models/posting.rb +11 -0
- data/test/test_helper.rb +51 -0
- data/test/unit/acts_methods_shoulda.rb +68 -0
- data/test/unit/class_methods_shoulda.rb +85 -0
- data/test/unit/common_methods_shoulda.rb +111 -0
- data/test/unit/instance_methods_shoulda.rb +318 -0
- data/test/unit/lazy_document_shoulda.rb +34 -0
- data/test/unit/parser_instance.rb +19 -0
- data/test/unit/parser_methods_shoulda.rb +268 -0
- data/test/unit/solr_instance.rb +44 -0
- data/test/unit/test_helper.rb +22 -0
- metadata +239 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
|
2
|
+
|
3
|
+
class UserModel; end
|
4
|
+
|
5
|
+
class LazyDocumentTest < Test::Unit::TestCase
|
6
|
+
context "With a lazy document" do
|
7
|
+
setup do
|
8
|
+
@record = stub(:record)
|
9
|
+
@record.stubs(:is_valid?).returns true
|
10
|
+
UserModel.stubs(:find).returns @record
|
11
|
+
@document = ActsAsSolr::LazyDocument.new(1, UserModel)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with an uninitialized document" do
|
15
|
+
should "fetch the record from the database" do
|
16
|
+
UserModel.expects(:find).with(1).returns(@record)
|
17
|
+
@document.is_valid?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with an initialized document" do
|
22
|
+
should "not fetch the record again" do
|
23
|
+
@document.is_valid?
|
24
|
+
@document.expects(:find).never
|
25
|
+
@document.is_valid?
|
26
|
+
end
|
27
|
+
|
28
|
+
should "reroute the calls to the record" do
|
29
|
+
@record.expects(:is_valid?).once
|
30
|
+
@document.is_valid?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ActsAsSolr::ParserInstance
|
2
|
+
include ActsAsSolr::ParserMethods
|
3
|
+
include ActsAsSolr::CommonMethods
|
4
|
+
attr_accessor :configuration, :solr_configuration
|
5
|
+
|
6
|
+
def table_name
|
7
|
+
"documents"
|
8
|
+
end
|
9
|
+
|
10
|
+
def primary_key
|
11
|
+
"id"
|
12
|
+
end
|
13
|
+
|
14
|
+
def find(*args)
|
15
|
+
[]
|
16
|
+
end
|
17
|
+
|
18
|
+
public :parse_results, :reorder, :parse_query, :add_scores, :replace_types
|
19
|
+
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
|
2
|
+
|
3
|
+
class ActsAsSolr::Post; end
|
4
|
+
|
5
|
+
class ParserMethodsTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "With a parser instance" do
|
8
|
+
setup do
|
9
|
+
@parser = ActsAsSolr::ParserInstance.new
|
10
|
+
end
|
11
|
+
|
12
|
+
context "When parsing results" do
|
13
|
+
setup do
|
14
|
+
@results = stub(:results)
|
15
|
+
@results.stubs(:total_hits).returns(2)
|
16
|
+
@results.stubs(:hits).returns([])
|
17
|
+
@results.stubs(:max_score).returns 2.1
|
18
|
+
@results.stubs(:data).returns({"responseHeader" => {"QTime" => "10.2"}})
|
19
|
+
end
|
20
|
+
|
21
|
+
should "return a SearchResults object" do
|
22
|
+
assert_equal ActsAsSolr::SearchResults, @parser.parse_results(@results).class
|
23
|
+
end
|
24
|
+
|
25
|
+
should "set the max score" do
|
26
|
+
assert_equal 2.1, @parser.parse_results(@results).max_score
|
27
|
+
end
|
28
|
+
|
29
|
+
should "include the facets" do
|
30
|
+
@results.stubs(:data).returns({"responseHeader" => {"QTime" => "10.2"}, "facet_counts" => 2})
|
31
|
+
assert_equal 2, @parser.parse_results(@results, :facets => true).facets
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when the format requests objects" do
|
35
|
+
setup do
|
36
|
+
@parser.configuration = {:format => :objects}
|
37
|
+
@parser.solr_configuration = {:primary_key_field => :pk_id}
|
38
|
+
@results.stubs(:hits).returns [{"pk_id" => 1}, {"pk_id" => 2}]
|
39
|
+
@parser.stubs(:reorder)
|
40
|
+
end
|
41
|
+
|
42
|
+
should "query with the record ids" do
|
43
|
+
@parser.expects(:find).with(:all, :conditions => ["documents.id in (?)", [1, 2]]).returns [1, 2]
|
44
|
+
@parser.parse_results(@results)
|
45
|
+
end
|
46
|
+
|
47
|
+
should "reorder the records" do
|
48
|
+
@parser.expects(:reorder).with([], [1, 2])
|
49
|
+
@parser.parse_results(@results)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "add :include if :include was specified" do
|
53
|
+
@parser.expects(:find).with(:all, :conditions => ["documents.id in (?)", [1, 2]], :include => [:author]).returns [1, 2]
|
54
|
+
@parser.parse_results(@results, :include => [:author])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "when the format doesn't request objects" do
|
59
|
+
setup do
|
60
|
+
@parser.solr_configuration = {:primary_key_field => "pk_id"}
|
61
|
+
end
|
62
|
+
|
63
|
+
should "not query the database" do
|
64
|
+
@parser.expects(:find).never
|
65
|
+
@parser.parse_results(@results, :format => nil)
|
66
|
+
end
|
67
|
+
|
68
|
+
should "return just the ids" do
|
69
|
+
@results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
|
70
|
+
assert_equal [1, 2], @parser.parse_results(@results, :format => nil).docs
|
71
|
+
end
|
72
|
+
|
73
|
+
should "ignore the :lazy option" do
|
74
|
+
@results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
|
75
|
+
assert_equal [1, 2], @parser.parse_results(@results, :format => :ids, :lazy => true).docs
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "with an empty result set" do
|
80
|
+
setup do
|
81
|
+
@results.stubs(:total_hits).returns(0)
|
82
|
+
@results.stubs(:hits).returns([])
|
83
|
+
end
|
84
|
+
|
85
|
+
should "return an empty search results set" do
|
86
|
+
assert_equal 0, @parser.parse_results(@results).total
|
87
|
+
end
|
88
|
+
|
89
|
+
should "not have any search results" do
|
90
|
+
assert_equal [], @parser.parse_results(@results).docs
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "with a nil result set" do
|
95
|
+
should "return an empty search results set" do
|
96
|
+
assert_equal 0, @parser.parse_results(nil).total
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "with the scores option" do
|
101
|
+
should "add the scores" do
|
102
|
+
@parser.expects(:add_scores).with([], @results)
|
103
|
+
@parser.parse_results(@results, :scores => true)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "with lazy format" do
|
108
|
+
setup do
|
109
|
+
@parser.solr_configuration = {:primary_key_field => :pk_id}
|
110
|
+
@results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
|
111
|
+
end
|
112
|
+
|
113
|
+
should "create LazyDocuments for the resulting docs" do
|
114
|
+
result = @parser.parse_results(@results, :lazy => true)
|
115
|
+
assert_equal ActsAsSolr::LazyDocument, result.results.first.class
|
116
|
+
end
|
117
|
+
|
118
|
+
should "set the document id as the record id" do
|
119
|
+
result = @parser.parse_results(@results, :lazy => true)
|
120
|
+
assert_equal 1, result.results.first.id
|
121
|
+
end
|
122
|
+
|
123
|
+
should "set the document class" do
|
124
|
+
result = @parser.parse_results(@results, :lazy => true)
|
125
|
+
assert_equal ActsAsSolr::ParserInstance, result.results.first.clazz.class
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
context "when reordering results" do
|
132
|
+
should "raise an error if arguments don't have the same number of elements" do
|
133
|
+
assert_raise(RuntimeError) {@parser.reorder([], [1])}
|
134
|
+
end
|
135
|
+
|
136
|
+
should "reorder the results to match the order of the documents returned by solr" do
|
137
|
+
thing1 = stub(:thing1)
|
138
|
+
thing1.stubs(:id).returns 5
|
139
|
+
thing2 = stub(:thing2)
|
140
|
+
thing2.stubs(:id).returns 1
|
141
|
+
thing3 = stub(:things3)
|
142
|
+
thing3.stubs(:id).returns 3
|
143
|
+
things = [thing1, thing2, thing3]
|
144
|
+
reordered = @parser.reorder(things, [1, 3, 5])
|
145
|
+
assert_equal [1, 3, 5], reordered.collect{|thing| thing.id}
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "When parsing a query" do
|
150
|
+
setup do
|
151
|
+
ActsAsSolr::Post.stubs(:execute)
|
152
|
+
@parser.stubs(:solr_type_condition).returns "(type:ParserMethodsTest)"
|
153
|
+
@parser.solr_configuration = {:primary_key_field => "id"}
|
154
|
+
@parser.configuration = {:solr_fields => nil}
|
155
|
+
end
|
156
|
+
|
157
|
+
should "set the limit and offset" do
|
158
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
159
|
+
10 == request.to_hash[:rows]
|
160
|
+
20 == request.to_hash[:start]
|
161
|
+
}
|
162
|
+
@parser.parse_query "foo", :limit => 10, :offset => 20
|
163
|
+
end
|
164
|
+
|
165
|
+
should "set the operator" do
|
166
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
167
|
+
"OR" == request.to_hash["q.op"]
|
168
|
+
}
|
169
|
+
@parser.parse_query "foo", :operator => :or
|
170
|
+
end
|
171
|
+
|
172
|
+
should "not execute anything if the query is nil" do
|
173
|
+
ActsAsSolr::Post.expects(:execute).never
|
174
|
+
assert_nil @parser.parse_query(nil)
|
175
|
+
end
|
176
|
+
|
177
|
+
should "not execute anything if the query is ''" do
|
178
|
+
ActsAsSolr::Post.expects(:execute).never
|
179
|
+
assert_nil @parser.parse_query('')
|
180
|
+
end
|
181
|
+
|
182
|
+
should "raise an error if invalid options where specified" do
|
183
|
+
assert_raise(RuntimeError) {@parser.parse_query "foo", :invalid => true}
|
184
|
+
end
|
185
|
+
|
186
|
+
should "add the type" do
|
187
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
188
|
+
request.to_hash[:q].include?("(type:ParserMethodsTest)")
|
189
|
+
}
|
190
|
+
@parser.parse_query "foo"
|
191
|
+
end
|
192
|
+
|
193
|
+
should "append the field types for the specified fields" do
|
194
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
195
|
+
request.to_hash[:q].include?("(username_t:Chunky)")
|
196
|
+
}
|
197
|
+
@parser.parse_query "username:Chunky"
|
198
|
+
end
|
199
|
+
|
200
|
+
should "replace the field types" do
|
201
|
+
@parser.expects(:replace_types).returns(["active_i:1"])
|
202
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
203
|
+
request.to_hash[:q].include?("active_i:1")
|
204
|
+
}
|
205
|
+
@parser.parse_query "active:1"
|
206
|
+
end
|
207
|
+
|
208
|
+
should "add score and primary key to field list" do
|
209
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
210
|
+
request.to_hash[:fl] == ('id,score')
|
211
|
+
}
|
212
|
+
@parser.parse_query "foo"
|
213
|
+
end
|
214
|
+
|
215
|
+
context "with the order option" do
|
216
|
+
should "add the order criteria to the query" do
|
217
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
218
|
+
request.to_hash[:q].include?(";active_t desc")
|
219
|
+
}
|
220
|
+
@parser.parse_query "active:1", :order => "active desc"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
context "with facets" do
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
context "When setting the field types" do
|
229
|
+
setup do
|
230
|
+
@parser.configuration = {:solr_fields => {:name => {:type => :string},
|
231
|
+
:age => {:type => :integer}}}
|
232
|
+
end
|
233
|
+
|
234
|
+
should "replace the _t suffix with the real type" do
|
235
|
+
assert_equal ["name_s:Chunky AND age_i:21"], @parser.replace_types(["name_t:Chunky AND age_t:21"])
|
236
|
+
end
|
237
|
+
|
238
|
+
context "with a suffix" do
|
239
|
+
should "not include the colon when false" do
|
240
|
+
assert_equal ["name_s"], @parser.replace_types(["name_t"], false)
|
241
|
+
end
|
242
|
+
|
243
|
+
should "include the colon by default" do
|
244
|
+
assert_equal ["name_s:Chunky"], @parser.replace_types(["name_t:Chunky"])
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
context "When adding scores" do
|
250
|
+
setup do
|
251
|
+
@solr_data = stub(:results)
|
252
|
+
@solr_data.stubs(:total_hits).returns(1)
|
253
|
+
@solr_data.stubs(:hits).returns([{"id" => 2, "score" => 2.546}])
|
254
|
+
@solr_data.stubs(:max_score).returns 2.1
|
255
|
+
|
256
|
+
@results = [Array.new]
|
257
|
+
|
258
|
+
@parser.stubs(:record_id).returns(2)
|
259
|
+
|
260
|
+
@parser.solr_configuration = {:primary_key_field => "id"}
|
261
|
+
end
|
262
|
+
|
263
|
+
should "add the score to the result document" do
|
264
|
+
assert_equal 2.546, @parser.add_scores(@results, @solr_data).first.last.solr_score
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class SolrInstance
|
2
|
+
include ActsAsSolr::InstanceMethods
|
3
|
+
attr_accessor :configuration, :solr_configuration, :name
|
4
|
+
|
5
|
+
def initialize(name = "Chunky bacon!")
|
6
|
+
@name = name
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.primary_key
|
10
|
+
"id"
|
11
|
+
end
|
12
|
+
|
13
|
+
def logger
|
14
|
+
@logger ||= Logger.new(StringIO.new)
|
15
|
+
end
|
16
|
+
|
17
|
+
def record_id(obj)
|
18
|
+
10
|
19
|
+
end
|
20
|
+
|
21
|
+
def boost_rate
|
22
|
+
10.0
|
23
|
+
end
|
24
|
+
|
25
|
+
def irate
|
26
|
+
8.0
|
27
|
+
end
|
28
|
+
|
29
|
+
def name_for_solr
|
30
|
+
name
|
31
|
+
end
|
32
|
+
|
33
|
+
def id_for_solr
|
34
|
+
"bogus"
|
35
|
+
end
|
36
|
+
|
37
|
+
def type_for_solr
|
38
|
+
"humbug"
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_solr_field_type(args)
|
42
|
+
"s"
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "lib"))
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'acts_as_solr'
|
6
|
+
require 'mocha'
|
7
|
+
require 'active_support'
|
8
|
+
require 'logger'
|
9
|
+
require 'solr_instance'
|
10
|
+
require 'parser_instance'
|
11
|
+
require 'erb'
|
12
|
+
require 'ostruct'
|
13
|
+
|
14
|
+
if RUBY_VERSION =~ /^1\.9/
|
15
|
+
puts "\nRunning the unit test suite doesn't as of yet work with Ruby 1.9, because Mocha hasn't yet been updated to use minitest."
|
16
|
+
puts
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'mocha'
|
21
|
+
gem 'thoughtbot-shoulda'
|
22
|
+
require 'shoulda'
|
metadata
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: honkster-acts_as_solr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mathias Meyer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-20 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "This plugin adds full text search capabilities and many other nifty features from Apache\xD4s Solr to any Rails model. I'm currently rearranging the test suite to include a real unit test suite, and adding a few features I need myself."
|
17
|
+
email: meyer@paperplanes.de
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.markdown
|
25
|
+
- README.rdoc
|
26
|
+
files:
|
27
|
+
- CHANGE_LOG
|
28
|
+
- LICENSE
|
29
|
+
- README.markdown
|
30
|
+
- README.rdoc
|
31
|
+
- Rakefile
|
32
|
+
- TESTING_THE_PLUGIN
|
33
|
+
- VERSION
|
34
|
+
- lib/acts_as_solr.rb
|
35
|
+
- lib/acts_as_solr/acts_methods.rb
|
36
|
+
- lib/acts_as_solr/class_methods.rb
|
37
|
+
- lib/acts_as_solr/common_methods.rb
|
38
|
+
- lib/acts_as_solr/deprecation.rb
|
39
|
+
- lib/acts_as_solr/instance_methods.rb
|
40
|
+
- lib/acts_as_solr/lazy_document.rb
|
41
|
+
- lib/acts_as_solr/parser_methods.rb
|
42
|
+
- lib/acts_as_solr/search_results.rb
|
43
|
+
- lib/acts_as_solr/solr_fixtures.rb
|
44
|
+
- lib/acts_as_solr/tasks.rb
|
45
|
+
- lib/acts_as_solr/tasks/database.rake
|
46
|
+
- lib/acts_as_solr/tasks/solr.rake
|
47
|
+
- lib/acts_as_solr/tasks/test.rake
|
48
|
+
- lib/solr.rb
|
49
|
+
- lib/solr/connection.rb
|
50
|
+
- lib/solr/document.rb
|
51
|
+
- lib/solr/exception.rb
|
52
|
+
- lib/solr/field.rb
|
53
|
+
- lib/solr/importer.rb
|
54
|
+
- lib/solr/importer/array_mapper.rb
|
55
|
+
- lib/solr/importer/delimited_file_source.rb
|
56
|
+
- lib/solr/importer/hpricot_mapper.rb
|
57
|
+
- lib/solr/importer/mapper.rb
|
58
|
+
- lib/solr/importer/solr_source.rb
|
59
|
+
- lib/solr/importer/xpath_mapper.rb
|
60
|
+
- lib/solr/indexer.rb
|
61
|
+
- lib/solr/request.rb
|
62
|
+
- lib/solr/request/add_document.rb
|
63
|
+
- lib/solr/request/base.rb
|
64
|
+
- lib/solr/request/commit.rb
|
65
|
+
- lib/solr/request/delete.rb
|
66
|
+
- lib/solr/request/dismax.rb
|
67
|
+
- lib/solr/request/index_info.rb
|
68
|
+
- lib/solr/request/modify_document.rb
|
69
|
+
- lib/solr/request/optimize.rb
|
70
|
+
- lib/solr/request/ping.rb
|
71
|
+
- lib/solr/request/select.rb
|
72
|
+
- lib/solr/request/spellcheck.rb
|
73
|
+
- lib/solr/request/standard.rb
|
74
|
+
- lib/solr/request/update.rb
|
75
|
+
- lib/solr/response.rb
|
76
|
+
- lib/solr/response/add_document.rb
|
77
|
+
- lib/solr/response/base.rb
|
78
|
+
- lib/solr/response/commit.rb
|
79
|
+
- lib/solr/response/delete.rb
|
80
|
+
- lib/solr/response/dismax.rb
|
81
|
+
- lib/solr/response/index_info.rb
|
82
|
+
- lib/solr/response/modify_document.rb
|
83
|
+
- lib/solr/response/optimize.rb
|
84
|
+
- lib/solr/response/ping.rb
|
85
|
+
- lib/solr/response/ruby.rb
|
86
|
+
- lib/solr/response/select.rb
|
87
|
+
- lib/solr/response/spellcheck.rb
|
88
|
+
- lib/solr/response/standard.rb
|
89
|
+
- lib/solr/response/xml.rb
|
90
|
+
- lib/solr/solrtasks.rb
|
91
|
+
- lib/solr/util.rb
|
92
|
+
- lib/solr/xml.rb
|
93
|
+
- solr/CHANGES.txt
|
94
|
+
- solr/LICENSE.txt
|
95
|
+
- solr/NOTICE.txt
|
96
|
+
- solr/etc/jetty.xml
|
97
|
+
- solr/etc/webdefault.xml
|
98
|
+
- solr/lib/easymock.jar
|
99
|
+
- solr/lib/jetty-6.1.3.jar
|
100
|
+
- solr/lib/jetty-util-6.1.3.jar
|
101
|
+
- solr/lib/jsp-2.1/ant-1.6.5.jar
|
102
|
+
- solr/lib/jsp-2.1/core-3.1.1.jar
|
103
|
+
- solr/lib/jsp-2.1/jsp-2.1.jar
|
104
|
+
- solr/lib/jsp-2.1/jsp-api-2.1.jar
|
105
|
+
- solr/lib/servlet-api-2.4.jar
|
106
|
+
- solr/lib/servlet-api-2.5-6.1.3.jar
|
107
|
+
- solr/lib/xpp3-1.1.3.4.O.jar
|
108
|
+
- solr/solr/README.txt
|
109
|
+
- solr/solr/bin/abc
|
110
|
+
- solr/solr/bin/abo
|
111
|
+
- solr/solr/bin/backup
|
112
|
+
- solr/solr/bin/backupcleaner
|
113
|
+
- solr/solr/bin/commit
|
114
|
+
- solr/solr/bin/optimize
|
115
|
+
- solr/solr/bin/readercycle
|
116
|
+
- solr/solr/bin/rsyncd-disable
|
117
|
+
- solr/solr/bin/rsyncd-enable
|
118
|
+
- solr/solr/bin/rsyncd-start
|
119
|
+
- solr/solr/bin/rsyncd-stop
|
120
|
+
- solr/solr/bin/scripts-util
|
121
|
+
- solr/solr/bin/snapcleaner
|
122
|
+
- solr/solr/bin/snapinstaller
|
123
|
+
- solr/solr/bin/snappuller
|
124
|
+
- solr/solr/bin/snappuller-disable
|
125
|
+
- solr/solr/bin/snappuller-enable
|
126
|
+
- solr/solr/bin/snapshooter
|
127
|
+
- solr/solr/conf/admin-extra.html
|
128
|
+
- solr/solr/conf/protwords.txt
|
129
|
+
- solr/solr/conf/schema.xml
|
130
|
+
- solr/solr/conf/scripts.conf
|
131
|
+
- solr/solr/conf/solrconfig.xml
|
132
|
+
- solr/solr/conf/stopwords.txt
|
133
|
+
- solr/solr/conf/synonyms.txt
|
134
|
+
- solr/solr/conf/xslt/example.xsl
|
135
|
+
- solr/solr/conf/xslt/example_atom.xsl
|
136
|
+
- solr/solr/conf/xslt/example_rss.xsl
|
137
|
+
- solr/start.jar
|
138
|
+
- solr/webapps/solr.war
|
139
|
+
- test/config/solr.yml
|
140
|
+
- test/db/connections/mysql/connection.rb
|
141
|
+
- test/db/connections/sqlite/connection.rb
|
142
|
+
- test/db/migrate/001_create_books.rb
|
143
|
+
- test/db/migrate/002_create_movies.rb
|
144
|
+
- test/db/migrate/003_create_categories.rb
|
145
|
+
- test/db/migrate/004_create_electronics.rb
|
146
|
+
- test/db/migrate/005_create_authors.rb
|
147
|
+
- test/db/migrate/006_create_postings.rb
|
148
|
+
- test/db/migrate/007_create_posts.rb
|
149
|
+
- test/db/migrate/008_create_gadgets.rb
|
150
|
+
- test/fixtures/authors.yml
|
151
|
+
- test/fixtures/books.yml
|
152
|
+
- test/fixtures/categories.yml
|
153
|
+
- test/fixtures/db_definitions/mysql.sql
|
154
|
+
- test/fixtures/electronics.yml
|
155
|
+
- test/fixtures/movies.yml
|
156
|
+
- test/fixtures/postings.yml
|
157
|
+
- test/functional/acts_as_solr_test.rb
|
158
|
+
- test/functional/association_indexing_test.rb
|
159
|
+
- test/functional/faceted_search_test.rb
|
160
|
+
- test/functional/multi_solr_search_test.rb
|
161
|
+
- test/models/author.rb
|
162
|
+
- test/models/book.rb
|
163
|
+
- test/models/category.rb
|
164
|
+
- test/models/electronic.rb
|
165
|
+
- test/models/gadget.rb
|
166
|
+
- test/models/movie.rb
|
167
|
+
- test/models/novel.rb
|
168
|
+
- test/models/post.rb
|
169
|
+
- test/models/posting.rb
|
170
|
+
- test/test_helper.rb
|
171
|
+
- test/unit/acts_methods_shoulda.rb
|
172
|
+
- test/unit/class_methods_shoulda.rb
|
173
|
+
- test/unit/common_methods_shoulda.rb
|
174
|
+
- test/unit/instance_methods_shoulda.rb
|
175
|
+
- test/unit/lazy_document_shoulda.rb
|
176
|
+
- test/unit/parser_instance.rb
|
177
|
+
- test/unit/parser_methods_shoulda.rb
|
178
|
+
- test/unit/solr_instance.rb
|
179
|
+
- test/unit/test_helper.rb
|
180
|
+
has_rdoc: false
|
181
|
+
homepage: http://github.com/mattmatt/acts_as_solr
|
182
|
+
post_install_message:
|
183
|
+
rdoc_options:
|
184
|
+
- --charset=UTF-8
|
185
|
+
require_paths:
|
186
|
+
- lib
|
187
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: "0"
|
192
|
+
version:
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: "0"
|
198
|
+
version:
|
199
|
+
requirements: []
|
200
|
+
|
201
|
+
rubyforge_project:
|
202
|
+
rubygems_version: 1.2.0
|
203
|
+
signing_key:
|
204
|
+
specification_version: 3
|
205
|
+
summary: "This plugin adds full text search capabilities and many other nifty features from Apache\xD4s Solr to any Rails model. I'm currently rearranging the test suite to include a real unit test suite, and adding a few features I need myself."
|
206
|
+
test_files:
|
207
|
+
- test/db/connections/mysql/connection.rb
|
208
|
+
- test/db/connections/sqlite/connection.rb
|
209
|
+
- test/db/migrate/001_create_books.rb
|
210
|
+
- test/db/migrate/002_create_movies.rb
|
211
|
+
- test/db/migrate/003_create_categories.rb
|
212
|
+
- test/db/migrate/004_create_electronics.rb
|
213
|
+
- test/db/migrate/005_create_authors.rb
|
214
|
+
- test/db/migrate/006_create_postings.rb
|
215
|
+
- test/db/migrate/007_create_posts.rb
|
216
|
+
- test/db/migrate/008_create_gadgets.rb
|
217
|
+
- test/functional/acts_as_solr_test.rb
|
218
|
+
- test/functional/association_indexing_test.rb
|
219
|
+
- test/functional/faceted_search_test.rb
|
220
|
+
- test/functional/multi_solr_search_test.rb
|
221
|
+
- test/models/author.rb
|
222
|
+
- test/models/book.rb
|
223
|
+
- test/models/category.rb
|
224
|
+
- test/models/electronic.rb
|
225
|
+
- test/models/gadget.rb
|
226
|
+
- test/models/movie.rb
|
227
|
+
- test/models/novel.rb
|
228
|
+
- test/models/post.rb
|
229
|
+
- test/models/posting.rb
|
230
|
+
- test/test_helper.rb
|
231
|
+
- test/unit/acts_methods_shoulda.rb
|
232
|
+
- test/unit/class_methods_shoulda.rb
|
233
|
+
- test/unit/common_methods_shoulda.rb
|
234
|
+
- test/unit/instance_methods_shoulda.rb
|
235
|
+
- test/unit/lazy_document_shoulda.rb
|
236
|
+
- test/unit/parser_instance.rb
|
237
|
+
- test/unit/parser_methods_shoulda.rb
|
238
|
+
- test/unit/solr_instance.rb
|
239
|
+
- test/unit/test_helper.rb
|