solrsam 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .gitCOMMIT_EDITMSG
2
+ .DS_Store
3
+ pkg/*
4
+ *.gem
5
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'activesupport'
4
+ gem 'activemodel'
5
+ gem 'rsolr', '1.0.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.2.0)
5
+ activesupport (= 3.2.0)
6
+ builder (~> 3.0.0)
7
+ activesupport (3.2.0)
8
+ i18n (~> 0.6)
9
+ multi_json (~> 1.0)
10
+ builder (3.0.0)
11
+ i18n (0.6.0)
12
+ multi_json (1.0.4)
13
+ rsolr (1.0.0)
14
+ builder (>= 2.1.2)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ activemodel
21
+ activesupport
22
+ rsolr (= 1.0.0)
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+ ---
3
+
4
+ Copyright (c) 2010 Tommy Chheng
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+
data/README.rdoc ADDED
@@ -0,0 +1,115 @@
1
+ = solrsan
2
+
3
+ http://github.com/tc/solrsan
4
+
5
+ This gem is a lightweight wrapper for the Apache Solr API.
6
+
7
+ Before you start, read the documentation for solr at http://wiki.apache.org/solr
8
+
9
+ It'll be invaluable for knowing parameters and error messages.
10
+ I made a few test cases for further examples at http://github.com/tc/solrsan/tree/master/test/unit
11
+
12
+ === HOWTO
13
+ Install Jetty
14
+
15
+ wget http://download.eclipse.org/jetty/7.3.0.v20110203/dist/jetty-distribution-7.3.0.v20110203.tar.gz
16
+ tar -zxvf jetty-distribution-*.tar.gz
17
+ rm jetty-distribution-*.tar.gz
18
+ mv jetty-distribution-* /usr/local
19
+ ln -s jetty-distribution-* jetty
20
+
21
+ Install solr
22
+
23
+
24
+ wget http://www.ecoficial.com/apachemirror/lucene/solr/3.1.0/apache-solr-3.1.0.tgz
25
+ tar -zxvf apache-solr-*.tgz
26
+ cd apache-solr-*
27
+ cp dist/apache-solr-*.war /usr/local/jetty/webapps/solr.war
28
+
29
+ Add solrsan to your Ruby application's Gemfile:
30
+ gem "solrsan"
31
+
32
+ Create solr configuration files using:
33
+ rails generate solrsan:config
34
+
35
+ The generator will copy the following files into your application.
36
+
37
+ config/solr.yml
38
+ config/solr
39
+ config/initializers/solrsan.rb
40
+ lib/tasks/solr.rake
41
+
42
+ Edit the config/solr.yml for your directory paths.
43
+
44
+ The rake file will add these rake tasks:
45
+
46
+ rake solr:start
47
+ rake solr:stop
48
+ rake solr:clear_index
49
+ rake solr:index
50
+
51
+ you will need to alter clear_index/index to match your models
52
+
53
+ Deploy tasks via capistrano:
54
+ add to your deploy.rb
55
+
56
+ require 'solrsan/capistrano'
57
+
58
+ This will add the following methods which will just call the
59
+ corresponding rake tasks:
60
+
61
+ cap solr:start
62
+ cap solr:stop
63
+ cap solr:reindex
64
+
65
+ === Indexing documents:
66
+ Edit config/solr/conf/schema.xml to state the types of fields you want
67
+ to index. You can use dynamic fields as well.
68
+
69
+ These fields are required for each solr document and are automatically
70
+ generated:
71
+
72
+ id, db_id, type
73
+
74
+ In your model, define as_solr_document and return a hash with specific fields.
75
+
76
+
77
+ class Document < ActiveRecord::Base
78
+ include Solrsan::Search
79
+ after_save :index
80
+ before_destroy :destroy_index_document
81
+
82
+ def as_solr_document
83
+ {:content => "hi"}
84
+ end
85
+ end
86
+
87
+
88
+ In each model, you can include a Solrsan::Search module which will include a few interface helper methods:
89
+ index
90
+ destroy_index_document
91
+ search(params)
92
+
93
+ === Search:
94
+ A simple search query:
95
+ Document.search(:q => "hello world")
96
+
97
+ More searching examples can be seen in test/unit/search_test.rb
98
+
99
+ == Changelog
100
+ 0.0.33
101
+ Reverted Hashwithindifferentaccess for request parsing, buggy with will_paginate.
102
+
103
+ 0.0.32
104
+ Using Hashwithindifferentaccess for request parsing.
105
+
106
+ 0.0.31
107
+ Usable version!
108
+
109
+ 0.0.1
110
+ First release.
111
+
112
+ == Copyright
113
+
114
+ Copyright (c) 2011 Tommy Chheng. See LICENSE for details.
115
+
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'bundler'
2
+ require 'rake/testtask'
3
+ Bundler::GemHelper.install_tasks
4
+ Dir[File.join(File.dirname(__FILE__), "lib", "tasks", "**", "*.rake")].each { |ext| load ext }
5
+
6
+ desc "Default: run all tests"
7
+ task :default => :test
8
+
9
+ desc "Run tests"
10
+ task :test => %w(test:units)
11
+ namespace :test do
12
+ desc "Run unit tests"
13
+ Rake::TestTask.new(:units) do |t|
14
+ t.libs << 'lib' << 'test'
15
+ t.test_files = FileList["test/unit/*_test.rb", "test/unit/*/*_test.rb"]
16
+ end
17
+ end
18
+
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!--
3
+ Licensed to the Apache Software Foundation (ASF) under one or more
4
+ contributor license agreements. See the NOTICE file distributed with
5
+ this work for additional information regarding copyright ownership.
6
+ The ASF licenses this file to You under the Apache License, Version 2.0
7
+ (the "License"); you may not use this file except in compliance with
8
+ the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ -->
18
+
19
+ <!-- If this file is found in the config directory, it will only be
20
+ loaded once at startup. If it is found in Solr's data
21
+ directory, it will be re-loaded every commit.
22
+ -->
23
+
24
+ <elevate>
25
+ <query text="foo bar">
26
+ <doc id="1" />
27
+ <doc id="2" />
28
+ <doc id="3" />
29
+ </query>
30
+
31
+ </elevate>
@@ -0,0 +1,246 @@
1
+ # The ASF licenses this file to You under the Apache License, Version 2.0
2
+ # (the "License"); you may not use this file except in compliance with
3
+ # the License. You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ # Syntax:
14
+ # "source" => "target"
15
+ # "source".length() > 0 (source cannot be empty.)
16
+ # "target".length() >= 0 (target can be empty.)
17
+
18
+ # example:
19
+ # "À" => "A"
20
+ # "\u00C0" => "A"
21
+ # "\u00C0" => "\u0041"
22
+ # "ß" => "ss"
23
+ # "\t" => " "
24
+ # "\n" => ""
25
+
26
+ # À => A
27
+ "\u00C0" => "A"
28
+
29
+ # Á => A
30
+ "\u00C1" => "A"
31
+
32
+ # Â => A
33
+ "\u00C2" => "A"
34
+
35
+ # Ã => A
36
+ "\u00C3" => "A"
37
+
38
+ # Ä => A
39
+ "\u00C4" => "A"
40
+
41
+ # Å => A
42
+ "\u00C5" => "A"
43
+
44
+ # Æ => AE
45
+ "\u00C6" => "AE"
46
+
47
+ # Ç => C
48
+ "\u00C7" => "C"
49
+
50
+ # È => E
51
+ "\u00C8" => "E"
52
+
53
+ # É => E
54
+ "\u00C9" => "E"
55
+
56
+ # Ê => E
57
+ "\u00CA" => "E"
58
+
59
+ # Ë => E
60
+ "\u00CB" => "E"
61
+
62
+ # Ì => I
63
+ "\u00CC" => "I"
64
+
65
+ # Í => I
66
+ "\u00CD" => "I"
67
+
68
+ # Î => I
69
+ "\u00CE" => "I"
70
+
71
+ # Ï => I
72
+ "\u00CF" => "I"
73
+
74
+ # IJ => IJ
75
+ "\u0132" => "IJ"
76
+
77
+ # Ð => D
78
+ "\u00D0" => "D"
79
+
80
+ # Ñ => N
81
+ "\u00D1" => "N"
82
+
83
+ # Ò => O
84
+ "\u00D2" => "O"
85
+
86
+ # Ó => O
87
+ "\u00D3" => "O"
88
+
89
+ # Ô => O
90
+ "\u00D4" => "O"
91
+
92
+ # Õ => O
93
+ "\u00D5" => "O"
94
+
95
+ # Ö => O
96
+ "\u00D6" => "O"
97
+
98
+ # Ø => O
99
+ "\u00D8" => "O"
100
+
101
+ # Œ => OE
102
+ "\u0152" => "OE"
103
+
104
+ # Þ
105
+ "\u00DE" => "TH"
106
+
107
+ # Ù => U
108
+ "\u00D9" => "U"
109
+
110
+ # Ú => U
111
+ "\u00DA" => "U"
112
+
113
+ # Û => U
114
+ "\u00DB" => "U"
115
+
116
+ # Ü => U
117
+ "\u00DC" => "U"
118
+
119
+ # Ý => Y
120
+ "\u00DD" => "Y"
121
+
122
+ # Ÿ => Y
123
+ "\u0178" => "Y"
124
+
125
+ # à => a
126
+ "\u00E0" => "a"
127
+
128
+ # á => a
129
+ "\u00E1" => "a"
130
+
131
+ # â => a
132
+ "\u00E2" => "a"
133
+
134
+ # ã => a
135
+ "\u00E3" => "a"
136
+
137
+ # ä => a
138
+ "\u00E4" => "a"
139
+
140
+ # å => a
141
+ "\u00E5" => "a"
142
+
143
+ # æ => ae
144
+ "\u00E6" => "ae"
145
+
146
+ # ç => c
147
+ "\u00E7" => "c"
148
+
149
+ # è => e
150
+ "\u00E8" => "e"
151
+
152
+ # é => e
153
+ "\u00E9" => "e"
154
+
155
+ # ê => e
156
+ "\u00EA" => "e"
157
+
158
+ # ë => e
159
+ "\u00EB" => "e"
160
+
161
+ # ì => i
162
+ "\u00EC" => "i"
163
+
164
+ # í => i
165
+ "\u00ED" => "i"
166
+
167
+ # î => i
168
+ "\u00EE" => "i"
169
+
170
+ # ï => i
171
+ "\u00EF" => "i"
172
+
173
+ # ij => ij
174
+ "\u0133" => "ij"
175
+
176
+ # ð => d
177
+ "\u00F0" => "d"
178
+
179
+ # ñ => n
180
+ "\u00F1" => "n"
181
+
182
+ # ò => o
183
+ "\u00F2" => "o"
184
+
185
+ # ó => o
186
+ "\u00F3" => "o"
187
+
188
+ # ô => o
189
+ "\u00F4" => "o"
190
+
191
+ # õ => o
192
+ "\u00F5" => "o"
193
+
194
+ # ö => o
195
+ "\u00F6" => "o"
196
+
197
+ # ø => o
198
+ "\u00F8" => "o"
199
+
200
+ # œ => oe
201
+ "\u0153" => "oe"
202
+
203
+ # ß => ss
204
+ "\u00DF" => "ss"
205
+
206
+ # þ => th
207
+ "\u00FE" => "th"
208
+
209
+ # ù => u
210
+ "\u00F9" => "u"
211
+
212
+ # ú => u
213
+ "\u00FA" => "u"
214
+
215
+ # û => u
216
+ "\u00FB" => "u"
217
+
218
+ # ü => u
219
+ "\u00FC" => "u"
220
+
221
+ # ý => y
222
+ "\u00FD" => "y"
223
+
224
+ # ÿ => y
225
+ "\u00FF" => "y"
226
+
227
+ # ff => ff
228
+ "\uFB00" => "ff"
229
+
230
+ # fi => fi
231
+ "\uFB01" => "fi"
232
+
233
+ # fl => fl
234
+ "\uFB02" => "fl"
235
+
236
+ # ffi => ffi
237
+ "\uFB03" => "ffi"
238
+
239
+ # ffl => ffl
240
+ "\uFB04" => "ffl"
241
+
242
+ # ſt => ft
243
+ "\uFB05" => "ft"
244
+
245
+ # st => st
246
+ "\uFB06" => "st"
@@ -0,0 +1,22 @@
1
+ # The ASF licenses this file to You under the Apache License, Version 2.0
2
+ # (the "License"); you may not use this file except in compliance with
3
+ # the License. You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ #-----------------------------------------------------------------------
14
+ # Use a protected word file to protect against the stemmer reducing two
15
+ # unrelated words to the same base word.
16
+
17
+ # Some non-words that normally won't be encountered,
18
+ # just to test that they won't be stemmed.
19
+ dontstems
20
+ zwhacky
21
+
22
+