solrsan 0.5.1 → 0.5.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/README.md +6 -3
- data/lib/solrsan/indexer.rb +3 -3
- data/lib/solrsan/version.rb +1 -1
- data/lib/tasks/solr.rake +1 -0
- data/test/unit/search_test.rb +17 -17
- metadata +8 -9
- data/Gemfile.lock +0 -29
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Install Jetty
|
|
24
24
|
Install solr
|
25
25
|
|
26
26
|
```
|
27
|
-
wget http://www.ecoficial.com/apachemirror/lucene/solr/3.4.0/apache-solr-3.
|
27
|
+
wget http://www.ecoficial.com/apachemirror/lucene/solr/3.4.0/apache-solr-3.5.0.tgz
|
28
28
|
tar -zxvf apache-solr-*.tgz
|
29
29
|
cd apache-solr-*
|
30
30
|
sudo cp dist/apache-solr-*.war /usr/local/jetty/webapps/solr.war
|
@@ -96,7 +96,7 @@ In your model, define as_solr_document and return a hash with specific fields.
|
|
96
96
|
```
|
97
97
|
class Document < ActiveRecord::Base
|
98
98
|
include Solrsan::Search
|
99
|
-
after_save :
|
99
|
+
after_save :solr_index
|
100
100
|
before_destroy :destroy_index_document
|
101
101
|
|
102
102
|
def as_solr_document
|
@@ -108,7 +108,7 @@ In your model, define as_solr_document and return a hash with specific fields.
|
|
108
108
|
In each model, you can include a Solrsan::Search module which will include a few interface helper methods:
|
109
109
|
|
110
110
|
```
|
111
|
-
|
111
|
+
solr_index
|
112
112
|
destroy_index_document
|
113
113
|
search(params)
|
114
114
|
```
|
@@ -123,6 +123,9 @@ A simple search query:
|
|
123
123
|
More searching examples can be seen in test/unit/search_test.rb
|
124
124
|
|
125
125
|
## Changelog
|
126
|
+
0.5.2
|
127
|
+
Renamed index to solr_index to avoid naming conflict with mongoid.
|
128
|
+
|
126
129
|
0.5.1
|
127
130
|
Added solr:setup rake/cap task
|
128
131
|
|
data/lib/solrsan/indexer.rb
CHANGED
@@ -22,8 +22,8 @@ module Solrsan
|
|
22
22
|
doc.merge(converted_fields)
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
self.class.
|
25
|
+
def solr_index
|
26
|
+
self.class.solr_index(self)
|
27
27
|
end
|
28
28
|
|
29
29
|
def destroy_index_document
|
@@ -43,7 +43,7 @@ module Solrsan
|
|
43
43
|
end
|
44
44
|
|
45
45
|
module ClassMethods
|
46
|
-
def
|
46
|
+
def solr_index(doc)
|
47
47
|
solr_docs = []
|
48
48
|
if doc.respond_to?(:map)
|
49
49
|
solr_docs = doc.map{|document| document.indexed_fields }
|
data/lib/solrsan/version.rb
CHANGED
data/lib/tasks/solr.rake
CHANGED
@@ -37,6 +37,7 @@ namespace :solr do
|
|
37
37
|
run_system_command "tar -zxvf apache-solr-*.tgz"
|
38
38
|
run_system_command "sudo cp apache-solr-*/dist/apache-solr-*.war #{jetty_path}/webapps/solr.war"
|
39
39
|
run_system_command "sudo mkdir -p #{solr_data_dir}"
|
40
|
+
run_system_command "sudo chown $USER #{solr_data_dir}"
|
40
41
|
end
|
41
42
|
|
42
43
|
desc "Start solr"
|
data/test/unit/search_test.rb
CHANGED
@@ -14,7 +14,7 @@ class SearchTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_simple_query
|
17
|
-
Document.
|
17
|
+
Document.solr_index(@document)
|
18
18
|
q = @document.attributes[:title]
|
19
19
|
|
20
20
|
response = Document.search(:q => q)
|
@@ -24,8 +24,8 @@ class SearchTest < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_sort
|
27
|
-
Document.
|
28
|
-
Document.
|
27
|
+
Document.solr_index(Document.new(:id => 3, :title => "solar city",:review_count => 10))
|
28
|
+
Document.solr_index(Document.new(:id => 4, :title => "city solar", :review_count => 5))
|
29
29
|
|
30
30
|
q = "solar"
|
31
31
|
response = Document.search(:q => q, :sort => "review_count asc")
|
@@ -125,8 +125,8 @@ class SearchTest < Test::Unit::TestCase
|
|
125
125
|
|
126
126
|
|
127
127
|
def test_filter_query_mulitple_filters
|
128
|
-
Document.
|
129
|
-
Document.
|
128
|
+
Document.solr_index(Document.new(:id => 3, :author => "Bert", :title => "solr lucene",:review_count => 10, :tags => ['ruby']))
|
129
|
+
Document.solr_index(Document.new(:id => 4, :author => "Ernie", :title => "lucene solr", :review_count => 5, :tags => ['ruby', 'scala']))
|
130
130
|
|
131
131
|
response = Document.search(:q => "solr", :fq => {:tags => ["scala"], :author => "Ernie"})
|
132
132
|
docs = response[:docs]
|
@@ -140,8 +140,8 @@ class SearchTest < Test::Unit::TestCase
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def test_filter_query
|
143
|
-
Document.
|
144
|
-
Document.
|
143
|
+
Document.solr_index(Document.new(:id => 3, :author => "Bert", :title => "solr lucene",:review_count => 10, :tags => ['ruby']))
|
144
|
+
Document.solr_index(Document.new(:id => 4, :author => "Ernie", :title => "lucene solr", :review_count => 5, :tags => ['ruby', 'scala']))
|
145
145
|
|
146
146
|
response = Document.search(:q => "solr", :fq => [{:tags => ["scala"]}])
|
147
147
|
docs = response[:docs]
|
@@ -155,8 +155,8 @@ class SearchTest < Test::Unit::TestCase
|
|
155
155
|
end
|
156
156
|
|
157
157
|
def test_text_faceting
|
158
|
-
Document.
|
159
|
-
Document.
|
158
|
+
Document.solr_index(Document.new(:id => 3, :author => "Bert", :title => "solr lucene",:review_count => 10))
|
159
|
+
Document.solr_index(Document.new(:id => 4, :author => "Ernie", :title => "lucene solr", :review_count => 5))
|
160
160
|
|
161
161
|
response = Document.search(:q => "solr", :'facet.field' => ['author'])
|
162
162
|
docs = response[:docs]
|
@@ -168,8 +168,8 @@ class SearchTest < Test::Unit::TestCase
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def test_range_faceting
|
171
|
-
Document.
|
172
|
-
Document.
|
171
|
+
Document.solr_index(Document.new(:id => 3, :author => "Bert", :title => "solr lucene",:review_count => 10))
|
172
|
+
Document.solr_index(Document.new(:id => 4, :author => "Ernie", :title => "lucene solr", :review_count => 5))
|
173
173
|
|
174
174
|
response = Document.search(:q => "solr", :'facet.field' => ['author'], :'facet.query' => ["review_count:[1 TO 5]", "review_count:[6 TO 10]"])
|
175
175
|
docs = response[:docs]
|
@@ -181,7 +181,7 @@ class SearchTest < Test::Unit::TestCase
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def test_highlighting_support
|
184
|
-
Document.
|
184
|
+
Document.solr_index(Document.new(:id => 3, :author => "Bert", :title => "solr lucene",:review_count => 10, :tags => ["solr"]))
|
185
185
|
|
186
186
|
response = Document.search(:q => "solr",
|
187
187
|
:'hl.fl' => "*")
|
@@ -193,7 +193,7 @@ class SearchTest < Test::Unit::TestCase
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def test_embed_highlighting
|
196
|
-
Document.
|
196
|
+
Document.solr_index(Document.new(:id => 3, :author => "Bert", :title => "solr lucene",:review_count => 10, :tags => ["solr", "sphinx"]))
|
197
197
|
|
198
198
|
response = Document.search(:q => "solr",
|
199
199
|
:'hl.fl' => "*")
|
@@ -202,7 +202,7 @@ class SearchTest < Test::Unit::TestCase
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def test_debug_response
|
205
|
-
Document.
|
205
|
+
Document.solr_index(@document)
|
206
206
|
q = @document.attributes[:title]
|
207
207
|
|
208
208
|
response = Document.search({:q => q, :debugQuery => true})
|
@@ -211,7 +211,7 @@ class SearchTest < Test::Unit::TestCase
|
|
211
211
|
end
|
212
212
|
|
213
213
|
def test_stats_response
|
214
|
-
Document.
|
214
|
+
Document.solr_index(@document)
|
215
215
|
q = @document.attributes[:title]
|
216
216
|
|
217
217
|
response = Document.search({:q => q, :stats => true, :'stats.field' => 'review_count'})
|
@@ -220,8 +220,8 @@ class SearchTest < Test::Unit::TestCase
|
|
220
220
|
end
|
221
221
|
|
222
222
|
def test_will_paginate_support
|
223
|
-
Document.
|
224
|
-
Document.
|
223
|
+
Document.solr_index(Document.new(:id => 3, :author => "Bert", :title => "solr lucene",:review_count => 10))
|
224
|
+
Document.solr_index(Document.new(:id => 4, :author => "Ernie", :title => "lucene solr", :review_count => 5))
|
225
225
|
|
226
226
|
response = Document.search(:q => "solr")
|
227
227
|
docs = response[:docs]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solrsan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rsolr
|
16
|
-
requirement: &
|
16
|
+
requirement: &70260192595060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70260192595060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemodel
|
27
|
-
requirement: &
|
27
|
+
requirement: &70260192593880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.1.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70260192593880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activesupport
|
38
|
-
requirement: &
|
38
|
+
requirement: &70260192592320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 3.1.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70260192592320
|
47
47
|
description: solrsan is a lightweight wrapper for using Apache Solr within a Ruby
|
48
48
|
application including Rails and Sinatra.
|
49
49
|
email:
|
@@ -54,7 +54,6 @@ extra_rdoc_files: []
|
|
54
54
|
files:
|
55
55
|
- .gitignore
|
56
56
|
- Gemfile
|
57
|
-
- Gemfile.lock
|
58
57
|
- LICENSE
|
59
58
|
- README.md
|
60
59
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
solrsan (0.0.33)
|
5
|
-
activemodel (~> 3.1.1)
|
6
|
-
activesupport (~> 3.1.1)
|
7
|
-
rsolr (~> 1.0.3)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: http://rubygems.org/
|
11
|
-
specs:
|
12
|
-
activemodel (3.1.1)
|
13
|
-
activesupport (= 3.1.1)
|
14
|
-
builder (~> 3.0.0)
|
15
|
-
i18n (~> 0.6)
|
16
|
-
activesupport (3.1.1)
|
17
|
-
multi_json (~> 1.0)
|
18
|
-
builder (3.0.0)
|
19
|
-
i18n (0.6.0)
|
20
|
-
multi_json (1.0.3)
|
21
|
-
rsolr (1.0.3)
|
22
|
-
builder (= 3.0.0)
|
23
|
-
builder (>= 2.1.2)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
solrsan!
|