mwmitchell-rsolr 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +6 -0
- data/README.rdoc +11 -4
- data/examples/direct.rb +7 -2
- data/examples/http.rb +7 -2
- data/lib/rsolr.rb +7 -8
- data/test/connection/direct_test.rb +1 -1
- metadata +2 -2
data/CHANGES.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.8.2 - March 24, 2009
|
2
|
+
Changed RSolr.connect method to accept one options hash argument
|
3
|
+
- This hash gets passed to the Connection object and the adapter
|
4
|
+
Updated tests, examples and README.rdoc to reflect this change
|
5
|
+
Bumped the version up in gemspec and the RSolr module
|
6
|
+
|
1
7
|
0.8.1 - March 12, 2009
|
2
8
|
Added RSolr.escape and RSolr::Connection.new.escape
|
3
9
|
- tests in rsolr_test
|
data/README.rdoc
CHANGED
@@ -13,10 +13,10 @@ http://groups.google.com/group/rsolr
|
|
13
13
|
require 'rubygems'
|
14
14
|
require 'rsolr'
|
15
15
|
rsolr = RSolr.connect
|
16
|
-
response = rsolr.select(:q=>'*:*') #
|
16
|
+
response = rsolr.select(:q=>'*:*') # sends a request to /solr/select?q=*:*
|
17
17
|
|
18
18
|
# can also set the request handler path like:
|
19
|
-
response = rsolr.send_request('/catalog', :q=>'*:*') #
|
19
|
+
response = rsolr.send_request('/catalog', :q=>'*:*') # sends a request to /solr/catalog?q=*:*
|
20
20
|
|
21
21
|
To run tests:
|
22
22
|
|
@@ -29,10 +29,17 @@ To get a connection in MRI/standard Ruby:
|
|
29
29
|
|
30
30
|
solr = RSolr.connect
|
31
31
|
|
32
|
-
To
|
32
|
+
To change the Solr HTTP host:
|
33
33
|
|
34
|
-
solr = RSolr.connect(
|
34
|
+
solr = RSolr.connect(:url=>'http://solrserver.com')
|
35
35
|
|
36
|
+
To get a direct connection (no http) in jRuby using DirectSolrConnection:
|
37
|
+
|
38
|
+
solr = RSolr.connect({
|
39
|
+
:adapter=>:direct,
|
40
|
+
:home_dir=>'/path/to/solr/home',
|
41
|
+
:dist_dir=>'/path/to/solr/distribution'
|
42
|
+
)
|
36
43
|
|
37
44
|
== Requests
|
38
45
|
Once you have a connection, you can execute queries, updates etc..
|
data/examples/direct.rb
CHANGED
@@ -5,9 +5,14 @@ base = File.expand_path( File.dirname(__FILE__) )
|
|
5
5
|
dist = File.join(base, '..', 'apache-solr')
|
6
6
|
home = File.join(dist, 'example', 'solr')
|
7
7
|
|
8
|
-
solr = RSolr.connect(
|
8
|
+
solr = RSolr.connect(:adapter=>:direct, :home_dir=>home, :dist_dir=>dist)
|
9
9
|
|
10
|
-
|
10
|
+
Dir['../apache-solr/example/exampledocs/*.xml'].each do |xml_file|
|
11
|
+
puts "Updating with #{xml_file}"
|
12
|
+
solr.update File.read(xml_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
puts
|
11
16
|
|
12
17
|
response = solr.select :q=>'ipod', :fq=>'price:[0 TO 50]', :rows=>2, :start=>0
|
13
18
|
|
data/examples/http.rb
CHANGED
@@ -3,9 +3,14 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'rsolr')
|
|
3
3
|
solr = RSolr.connect
|
4
4
|
|
5
5
|
# switch out the http adapter from curb to net_http (just for an example)
|
6
|
-
solr.adapter.connector.adapter_name = :
|
6
|
+
solr.adapter.connector.adapter_name = :curb
|
7
7
|
|
8
|
-
|
8
|
+
Dir['../apache-solr/example/exampledocs/*.xml'].each do |xml_file|
|
9
|
+
puts "Updating with #{xml_file}"
|
10
|
+
solr.update File.read(xml_file)
|
11
|
+
end
|
12
|
+
|
13
|
+
puts
|
9
14
|
|
10
15
|
solr.select(:q=>'ipod', :fq=>'price:[0 TO 50]', :rows=>2, :start=>0) do |solr_response,adapter_response|
|
11
16
|
puts "URL : #{adapter_response[:url]}"
|
data/lib/rsolr.rb
CHANGED
@@ -7,7 +7,7 @@ proc {|base, files|
|
|
7
7
|
|
8
8
|
module RSolr
|
9
9
|
|
10
|
-
VERSION = '0.8.
|
10
|
+
VERSION = '0.8.2'
|
11
11
|
|
12
12
|
autoload :Message, 'rsolr/message'
|
13
13
|
autoload :Connection, 'rsolr/connection'
|
@@ -15,18 +15,17 @@ module RSolr
|
|
15
15
|
autoload :HTTPClient, 'rsolr/http_client'
|
16
16
|
|
17
17
|
# factory for creating connections
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
adapter_name = connection_opts[:adapter] ||= :http
|
18
|
+
# "options" is a hash that gets used by the Connection
|
19
|
+
# object AND the adapter object.
|
20
|
+
def self.connect(options={})
|
21
|
+
adapter_name = options[:adapter] ||= :http
|
23
22
|
types = {
|
24
23
|
:http=>'HTTP',
|
25
24
|
:direct=>'Direct'
|
26
25
|
}
|
27
26
|
adapter_class = RSolr::Adapter.const_get(types[adapter_name])
|
28
|
-
adapter = adapter_class.new(
|
29
|
-
RSolr::Connection.new(adapter,
|
27
|
+
adapter = adapter_class.new(options)
|
28
|
+
RSolr::Connection.new(adapter, options)
|
30
29
|
end
|
31
30
|
|
32
31
|
module Char
|
@@ -11,7 +11,7 @@ if defined?(JRUBY_VERSION)
|
|
11
11
|
base = File.expand_path( File.dirname(__FILE__) )
|
12
12
|
dist = File.join(base, '..', '..', 'apache-solr')
|
13
13
|
home = File.join(dist, 'example', 'solr')
|
14
|
-
@solr = RSolr.connect(
|
14
|
+
@solr = RSolr.connect(:adapter=>:direct, :home_dir=>home, :dist_dir=>dist)
|
15
15
|
@solr.delete_by_query('*:*')
|
16
16
|
@solr.commit
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mwmitchell-rsolr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Mitchell
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|