rsolr-direct 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/README.rdoc +11 -5
  2. data/Rakefile +3 -3
  3. data/VERSION +1 -1
  4. data/lib/rsolr-direct.rb +45 -55
  5. data/spec/rsolr-direct_spec.rb +12 -12
  6. metadata +29 -72
  7. data/solr/dist/apache-solr-1.4.0.war +0 -0
  8. data/solr/dist/apache-solr-cell-1.4.0.jar +0 -0
  9. data/solr/dist/apache-solr-clustering-1.4.0.jar +0 -0
  10. data/solr/dist/apache-solr-core-1.4.0.jar +0 -0
  11. data/solr/dist/apache-solr-dataimporthandler-1.4.0.jar +0 -0
  12. data/solr/dist/apache-solr-dataimporthandler-extras-1.4.0.jar +0 -0
  13. data/solr/dist/apache-solr-solrj-1.4.0.jar +0 -0
  14. data/solr/lib/commons-codec-1.3.jar +0 -0
  15. data/solr/lib/commons-csv-1.0-SNAPSHOT-r609327.jar +0 -0
  16. data/solr/lib/commons-fileupload-1.2.1.jar +0 -0
  17. data/solr/lib/commons-httpclient-3.1.jar +0 -0
  18. data/solr/lib/commons-io-1.4.jar +0 -0
  19. data/solr/lib/easymock.jar +0 -0
  20. data/solr/lib/geronimo-stax-api_1.0_spec-1.0.1.jar +0 -0
  21. data/solr/lib/jcl-over-slf4j-1.5.5.jar +0 -0
  22. data/solr/lib/junit-4.3.jar +0 -0
  23. data/solr/lib/lucene-analyzers-2.9.1.jar +0 -0
  24. data/solr/lib/lucene-core-2.9.1.jar +0 -0
  25. data/solr/lib/lucene-highlighter-2.9.1.jar +0 -0
  26. data/solr/lib/lucene-memory-2.9.1.jar +0 -0
  27. data/solr/lib/lucene-misc-2.9.1.jar +0 -0
  28. data/solr/lib/lucene-queries-2.9.1.jar +0 -0
  29. data/solr/lib/lucene-snowball-2.9.1.jar +0 -0
  30. data/solr/lib/lucene-spellchecker-2.9.1.jar +0 -0
  31. data/solr/lib/servlet-api-2.4.jar +0 -0
  32. data/solr/lib/slf4j-api-1.5.5.jar +0 -0
  33. data/solr/lib/slf4j-jdk14-1.5.5.jar +0 -0
  34. data/solr/lib/solr-commons-csv-pom.xml.template +0 -36
  35. data/solr/lib/wstx-asl-3.2.7.jar +0 -0
@@ -7,25 +7,31 @@ Check out the specs to see the various connection methods.
7
7
  == Solr Java libs/jars
8
8
  RSolr-Direct comes with the required Solr jars. If you'd like to use them, just call #load_java_libs:
9
9
  require 'rsolr-direct'
10
- RSolr.load_java_libs
10
+ RSolr::Direct.load_java_libs "path/to/solr/distribution"
11
11
  # create connection etc..
12
12
 
13
13
  ==:solr_home
14
14
  require 'rsolr-direct'
15
- connection = RSolr.connect :direct, :solr_home => '/absolute/path/to/solr/home'
15
+ connection = RSolr.direct_connect(
16
+ :solr_home => '/absolute/path/to/solr/home',
17
+ :data_dir => "/optional/path/to/data/dir")
16
18
 
17
19
  ==Java::OrgApacheSolrCore::SolrCore
18
20
  require 'rsolr-direct'
19
21
  core = org.apache.solr.core.SolrCore.new(nil, solr_data_path, solr_config, index_schema, dcore)
20
- connection = RSolr.connect :direct, core
22
+ connection = RSolr.direct_connect core
21
23
 
22
24
  ==Java::OrgApacheSolrServlet::DirectSolrConnection
23
25
  require 'rsolr-direct'
24
26
  dc = org.apache.solr.servlet.DirectSolrConnection.new(solr_home_path, solr_data_path, solr_log_path)
25
- connection = RSolr.connect :direct, dc
27
+ connection = RSolr.direct_connect dc
26
28
 
27
29
  = Why
28
- Using a direct connection to Solr can speed up indexing. How much faster? I have no idea yet. Numbers to come?
30
+ Using a direct connection to Solr can speed up indexing. How much faster? A page on the Solr Wiki says ~ 50% faster.
31
+
32
+ = Testing
33
+ Clone it, cd into the project dir and run:
34
+ jruby -S rake spec
29
35
 
30
36
  == Note on Patches/Pull Requests
31
37
 
data/Rakefile CHANGED
@@ -11,10 +11,10 @@ begin
11
11
  gem.homepage = "http://github.com/mwmitchell/rsolr-direct"
12
12
  gem.authors = ["Matt Mitchell"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency "rsolr", ">= 0.12.1"
14
+ gem.add_dependency "rsolr", ">= 1.0.0"
15
15
 
16
- gem.files = FileList['lib/**/*.rb', 'LICENSE', 'README.rdoc', 'VERSION', 'solr/dist/*', 'solr/lib/*']
17
- gem.test_files = ['spec/*', 'Rakefile', 'solr/dist/*', 'solr/lib/*', 'solr/example/solr/*']
16
+ gem.files = FileList['lib/**/*.rb', 'LICENSE', 'README.rdoc', 'VERSION']
17
+ gem.test_files = ['spec/*', 'Rakefile', 'solr/example/solr/*']
18
18
 
19
19
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
20
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 1.0.0
@@ -7,53 +7,45 @@ require 'rsolr'
7
7
  #
8
8
  module RSolr::Direct
9
9
 
10
- module Connectable
11
-
12
- # load the java libs that ship with rsolr-direct
13
- # RSolr.load_java_libs
14
- # rsolr = RSolr.connect :direct, :solr_home => ''
15
- def load_java_libs
16
- @java_libs_loaded ||= (
17
- base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'solr'))
18
- ['lib', 'dist'].each do |sub|
19
- Dir[File.join(base_dir, sub, '*.jar')].each do |jar|
20
- require jar
21
- end
22
- end
23
- true
24
- )
25
- end
26
-
27
- # RSolr.connect :direct, :solr_home => 'apache-solr/example/solr'
28
- # RSolr.connect :direct, java_solr_core
29
- # RSolr.connect :direct, java_direct_solr_connection
30
- def connect *args, &blk
31
- if args.first == :direct
32
- client = RSolr::Client.new RSolr::Direct::Connection.new(*args[1..-1])
33
- if block_given?
34
- yield client
35
- client.connection.close
36
- nil
37
- else
38
- client
10
+ # load the java libs that ship with rsolr-direct
11
+ # RSolr.load_java_libs
12
+ # rsolr = RSolr.connect :direct, :solr_home => ''
13
+ def self.load_java_libs apache_solr_dir
14
+ @java_libs_loaded ||= (
15
+ base_dir = File.expand_path(apache_solr_dir)
16
+ ['lib', 'dist'].each do |sub|
17
+ Dir[File.join(base_dir, sub, '*.jar')].each do |jar|
18
+ require jar
39
19
  end
20
+ end
21
+ true
22
+ )
23
+ end
24
+
25
+ RSolr.class_eval do
26
+ # RSolr.direct_connect :solr_home => 'apache-solr/example/solr'
27
+ # RSolr.direct_connect java_solr_core
28
+ # RSolr.direct_connect java_direct_solr_connection
29
+ def self.direct_connect *args, &blk
30
+ client = RSolr::Client.new(RSolr::Direct::Connection.new(*args), :url => false)
31
+ if block_given?
32
+ yield client
33
+ client.connection.close
34
+ nil
40
35
  else
41
- # use the original connect method
42
- super *args, &blk
36
+ client
43
37
  end
44
38
  end
45
-
46
39
  end
47
40
 
48
- RSolr.extend RSolr::Direct::Connectable
49
-
50
41
  class Connection
51
42
 
52
- include RSolr::Connection::Requestable
53
-
54
43
  attr_accessor :opts
55
44
 
56
45
  class MissingRequiredJavaLibs < RuntimeError
46
+ def to_s
47
+ "#{self.class} => Try loading with RSolr::Direct.load_java_libs(\"/path/to/solr-distribution\")"
48
+ end
57
49
  end
58
50
 
59
51
  class InvalidSolrHome < RuntimeError
@@ -64,13 +56,11 @@ module RSolr::Direct
64
56
  # then...
65
57
  # required: opts[:solr_home] is absolute path to solr home (the directory with "data", "config" etc.)
66
58
  def initialize opts
67
-
68
59
  begin
69
60
  org.apache.solr.servlet.DirectSolrConnection
70
61
  rescue NameError
71
62
  raise MissingRequiredJavaLibs
72
63
  end
73
-
74
64
  if opts.is_a?(Hash) and opts[:solr_home]
75
65
  raise InvalidSolrHome unless File.exists?(opts[:solr_home])
76
66
  opts[:data_dir] ||= File.join(opts[:solr_home], 'data')
@@ -80,6 +70,7 @@ module RSolr::Direct
80
70
  elsif opts.class.to_s == "Java::OrgApacheSolrServlet::DirectSolrConnection"
81
71
  @direct = opts
82
72
  end
73
+ self.direct
83
74
  end
84
75
 
85
76
  # sets the @direct instance variable if it has not yet been set
@@ -87,34 +78,33 @@ module RSolr::Direct
87
78
  @direct ||= org.apache.solr.servlet.DirectSolrConnection.new(opts[:solr_home], @opts[:data_dir], nil)
88
79
  end
89
80
 
81
+ # rsolr.connection.open
82
+ alias_method :open, :direct
83
+
90
84
  def close
91
85
  if @direct
92
86
  @direct.close
93
- puts "CLOSING -> #{@direct}"
94
87
  @direct = nil
95
88
  end
96
89
  end
97
90
 
98
- # send a request to the connection
99
- # request '/select', :q=>'something'
100
- # request '/update', :wt=>:xml, '</commit>'
101
- def request(path, params={}, data=nil, opts={})
102
- data = data.to_xml if data.respond_to?(:to_xml)
103
- url = build_url(path, params)
91
+ # send a request to the connection (this is called by rsolr)
92
+ def execute client, request_context
93
+ #data = request_context[:data]
94
+ #data = data.to_xml if data.respond_to?(:to_xml)
95
+ url = [request_context[:path], request_context[:query]].join("?")
96
+ url = "/" + url unless url[0].chr == "/"
104
97
  begin
105
- body = direct.request(url, data)
98
+ body = direct.request(url, request_context[:data])
106
99
  rescue
107
- raise RSolr::RequestError.new($!.message)
100
+ $!.extend RSolr::Error::SolrContext
101
+ $!.request = request_context
102
+ raise $!
108
103
  end
109
104
  {
110
- :status_code => 200,
111
- :url=>url,
112
- :body=>body,
113
- :path=>path,
114
- :params=>params,
115
- :data=>data,
116
- :headers => {},
117
- :message => ''
105
+ :status => 200,
106
+ :body => body,
107
+ :headers => {}
118
108
  }
119
109
  end
120
110
 
@@ -5,35 +5,35 @@ describe RSolr::Direct do
5
5
  context 'initialization' do
6
6
 
7
7
  it 'should modifiy RSolr' do
8
- RSolr.should be_a(RSolr::Direct::Connectable)
8
+ RSolr.should respond_to(:direct_connect)
9
9
  end
10
10
 
11
11
  it 'should not change the default connect behavior' do
12
- RSolr.connect.connection.should be_a(RSolr::Connection::NetHttp)
12
+ RSolr.connect.connection.should be_a(RSolr::Connection)
13
13
  end
14
14
 
15
15
  it 'should attempt to use a direct connect if :solr_home is set but raise a MissingRequiredJavaLibs' do
16
16
  lambda{
17
- RSolr.connect(:direct, nil)
17
+ RSolr.direct_connect(nil)
18
18
  }.should raise_error(RSolr::Direct::Connection::MissingRequiredJavaLibs)
19
19
  end
20
20
 
21
21
  it 'should attempt to use a direct connect if :solr_home is set but raise a InvalidSolrHome' do
22
22
  load_required_java_libs
23
23
  lambda{
24
- RSolr.connect(:direct, :solr_home=>'')
24
+ RSolr.direct_connect(:solr_home=>'')
25
25
  }.should raise_error(RSolr::Direct::Connection::InvalidSolrHome)
26
26
  end
27
27
 
28
28
  it 'should create direct connection succesfully' do
29
29
  load_required_java_libs
30
- RSolr.connect(:direct, :solr_home=>solr_home_dir).connection.should be_a(RSolr::Direct::Connection)
30
+ RSolr.direct_connect(:solr_home=>solr_home_dir).connection.should be_a(RSolr::Direct::Connection)
31
31
  end
32
32
 
33
33
  it 'should accept a Java::OrgApacheSolrCore::SolrCore' do
34
34
  load_required_java_libs
35
35
  core = new_solr_core solr_home_dir, solr_data_dir
36
- rsolr = RSolr.connect(:direct, core)
36
+ rsolr = RSolr.direct_connect(core)
37
37
  rsolr.should be_a(RSolr::Client)
38
38
  rsolr.connection.should be_a(RSolr::Direct::Connection)
39
39
  core.close
@@ -42,7 +42,7 @@ describe RSolr::Direct do
42
42
  it 'should accept a Java::OrgApacheSolrServlet::DirectSolrConnection' do
43
43
  load_required_java_libs
44
44
  dc = new_direct_solr_connection solr_home_dir, solr_data_dir
45
- rsolr = RSolr.connect(:direct, dc)
45
+ rsolr = RSolr.direct_connect(dc)
46
46
  rsolr.should be_a(RSolr::Client)
47
47
  rsolr.connection.should be_a(RSolr::Direct::Connection)
48
48
  dc.close
@@ -55,9 +55,9 @@ describe RSolr::Direct do
55
55
  def self.included base
56
56
  base.let(:connections){
57
57
  [
58
- RSolr.connect(:direct, :solr_home=>solr_home_dir),
59
- RSolr.connect(:direct, new_solr_core(solr_home_dir, solr_data_dir)),
60
- RSolr.connect(:direct, new_direct_solr_connection(solr_home_dir, solr_data_dir))
58
+ RSolr.direct_connect(:solr_home=>solr_home_dir),
59
+ RSolr.direct_connect(new_solr_core(solr_home_dir, solr_data_dir)),
60
+ RSolr.direct_connect(new_direct_solr_connection(solr_home_dir, solr_data_dir))
61
61
  ]
62
62
  }
63
63
  end
@@ -79,7 +79,7 @@ describe RSolr::Direct do
79
79
 
80
80
  it 'should automatically close when using the block style of connecting' do
81
81
  rsolr = nil
82
- RSolr.connect(:direct, :solr_home => solr_home_dir) do |client|
82
+ RSolr.direct_connect(:solr_home => solr_home_dir) do |client|
83
83
  rsolr = client
84
84
  client.connection.direct # <- connect
85
85
  rsolr.connection.instance_variable_get("@direct").should_not be(nil)
@@ -95,7 +95,7 @@ describe RSolr::Direct do
95
95
 
96
96
  it '(they) should return a solr response hash when calling select' do
97
97
  connections.each do |rsolr|
98
- response = rsolr.select(:q => '*:*')
98
+ response = rsolr.select(:params => {:q => '*:*'})
99
99
  response.should be_a(Hash)
100
100
  response.keys.should include("response", "responseHeader")
101
101
  rsolr.connection.close
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsolr-direct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Matt Mitchell
@@ -9,29 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-05 00:00:00 -05:00
17
+ date: 2011-01-22 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
23
31
  version: 1.2.9
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: rsolr
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
33
- version: 0.12.1
34
- version:
41
+ segments:
42
+ - 1
43
+ - 0
44
+ - 0
45
+ version: 1.0.0
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  description: Provides a non-http connection to your solr/lucene index
36
49
  email: goodieboy@gmail.com
37
50
  executables: []
@@ -46,35 +59,6 @@ files:
46
59
  - README.rdoc
47
60
  - VERSION
48
61
  - lib/rsolr-direct.rb
49
- - solr/dist/apache-solr-1.4.0.war
50
- - solr/dist/apache-solr-cell-1.4.0.jar
51
- - solr/dist/apache-solr-clustering-1.4.0.jar
52
- - solr/dist/apache-solr-core-1.4.0.jar
53
- - solr/dist/apache-solr-dataimporthandler-1.4.0.jar
54
- - solr/dist/apache-solr-dataimporthandler-extras-1.4.0.jar
55
- - solr/dist/apache-solr-solrj-1.4.0.jar
56
- - solr/lib/commons-codec-1.3.jar
57
- - solr/lib/commons-csv-1.0-SNAPSHOT-r609327.jar
58
- - solr/lib/commons-fileupload-1.2.1.jar
59
- - solr/lib/commons-httpclient-3.1.jar
60
- - solr/lib/commons-io-1.4.jar
61
- - solr/lib/easymock.jar
62
- - solr/lib/geronimo-stax-api_1.0_spec-1.0.1.jar
63
- - solr/lib/jcl-over-slf4j-1.5.5.jar
64
- - solr/lib/junit-4.3.jar
65
- - solr/lib/lucene-analyzers-2.9.1.jar
66
- - solr/lib/lucene-core-2.9.1.jar
67
- - solr/lib/lucene-highlighter-2.9.1.jar
68
- - solr/lib/lucene-memory-2.9.1.jar
69
- - solr/lib/lucene-misc-2.9.1.jar
70
- - solr/lib/lucene-queries-2.9.1.jar
71
- - solr/lib/lucene-snowball-2.9.1.jar
72
- - solr/lib/lucene-spellchecker-2.9.1.jar
73
- - solr/lib/servlet-api-2.4.jar
74
- - solr/lib/slf4j-api-1.5.5.jar
75
- - solr/lib/slf4j-jdk14-1.5.5.jar
76
- - solr/lib/solr-commons-csv-pom.xml.template
77
- - solr/lib/wstx-asl-3.2.7.jar
78
62
  has_rdoc: true
79
63
  homepage: http://github.com/mwmitchell/rsolr-direct
80
64
  licenses: []
@@ -88,18 +72,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
72
  requirements:
89
73
  - - ">="
90
74
  - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
91
77
  version: "0"
92
- version:
93
78
  required_rubygems_version: !ruby/object:Gem::Requirement
94
79
  requirements:
95
80
  - - ">="
96
81
  - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
97
84
  version: "0"
98
- version:
99
85
  requirements: []
100
86
 
101
87
  rubyforge_project:
102
- rubygems_version: 1.3.5
88
+ rubygems_version: 1.3.6
103
89
  signing_key:
104
90
  specification_version: 3
105
91
  summary: A JRuby, direct connection for RSolr
@@ -108,33 +94,4 @@ test_files:
108
94
  - spec/spec.opts
109
95
  - spec/spec_helper.rb
110
96
  - Rakefile
111
- - solr/dist/apache-solr-1.4.0.war
112
- - solr/dist/apache-solr-cell-1.4.0.jar
113
- - solr/dist/apache-solr-clustering-1.4.0.jar
114
- - solr/dist/apache-solr-core-1.4.0.jar
115
- - solr/dist/apache-solr-dataimporthandler-1.4.0.jar
116
- - solr/dist/apache-solr-dataimporthandler-extras-1.4.0.jar
117
- - solr/dist/apache-solr-solrj-1.4.0.jar
118
- - solr/lib/commons-codec-1.3.jar
119
- - solr/lib/commons-csv-1.0-SNAPSHOT-r609327.jar
120
- - solr/lib/commons-fileupload-1.2.1.jar
121
- - solr/lib/commons-httpclient-3.1.jar
122
- - solr/lib/commons-io-1.4.jar
123
- - solr/lib/easymock.jar
124
- - solr/lib/geronimo-stax-api_1.0_spec-1.0.1.jar
125
- - solr/lib/jcl-over-slf4j-1.5.5.jar
126
- - solr/lib/junit-4.3.jar
127
- - solr/lib/lucene-analyzers-2.9.1.jar
128
- - solr/lib/lucene-core-2.9.1.jar
129
- - solr/lib/lucene-highlighter-2.9.1.jar
130
- - solr/lib/lucene-memory-2.9.1.jar
131
- - solr/lib/lucene-misc-2.9.1.jar
132
- - solr/lib/lucene-queries-2.9.1.jar
133
- - solr/lib/lucene-snowball-2.9.1.jar
134
- - solr/lib/lucene-spellchecker-2.9.1.jar
135
- - solr/lib/servlet-api-2.4.jar
136
- - solr/lib/slf4j-api-1.5.5.jar
137
- - solr/lib/slf4j-jdk14-1.5.5.jar
138
- - solr/lib/solr-commons-csv-pom.xml.template
139
- - solr/lib/wstx-asl-3.2.7.jar
140
97
  - solr/example/solr/README.txt
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,36 +0,0 @@
1
- <project xmlns="http://maven.apache.org/POM/4.0.0"
2
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
-
5
- <!--
6
- Licensed to the Apache Software Foundation (ASF) under one
7
- or more contributor license agreements. See the NOTICE file
8
- distributed with this work for additional information
9
- regarding copyright ownership. The ASF licenses this file
10
- to you under the Apache License, Version 2.0 (the
11
- "License"); you may not use this file except in compliance
12
- with the License. You may obtain a copy of the License at
13
-
14
- http://www.apache.org/licenses/LICENSE-2.0
15
-
16
- Unless required by applicable law or agreed to in writing,
17
- software distributed under the License is distributed on an
18
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- KIND, either express or implied. See the License for the
20
- specific language governing permissions and limitations
21
- under the License.
22
- -->
23
-
24
- <parent>
25
- <groupId>org.apache.solr</groupId>
26
- <artifactId>solr-parent</artifactId>
27
- <version>@maven_version@</version>
28
- </parent>
29
- <modelVersion>4.0.0</modelVersion>
30
- <groupId>org.apache.solr</groupId>
31
- <artifactId>solr-commons-csv</artifactId>
32
- <name>Solr Specific Commons CSV</name>
33
- <version>@maven_version@</version>
34
- <description>Solr Specific Commons CSV</description>
35
- <packaging>jar</packaging>
36
- </project>
Binary file