jruby-elasticsearch 0.0.15 → 0.0.16

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/jruby-elasticsearch/client.rb +52 -41
  3. metadata +15 -17
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6bd7db81e8b76fe90b5eb8a2a6b1cae7b37d7f4
4
+ data.tar.gz: 78cca76d3270554c79f8933457707ef52042d94a
5
+ SHA512:
6
+ metadata.gz: d43955a359b80bdc46751c5ad4d639b7dc1b36e202734e9afc40a18aac42172ea1756408bf2c9eca565a54073241eb550eb1467ab03a5265dd64c718a01e149e
7
+ data.tar.gz: f746bcb7c1b692f32e75aa731bb8960b43869989d26410d4897ed159faeb2923de8d427df21ee8f33426d630878be9e87b5039c5e371dcaf24021bd0a2ff2183
@@ -4,6 +4,8 @@ require "jruby-elasticsearch/indexrequest"
4
4
  require "jruby-elasticsearch/searchrequest"
5
5
 
6
6
  class ElasticSearch::Client
7
+ class Error < StandardError; end
8
+ class ConfigurationError < Error; end
7
9
 
8
10
  # Creates a new ElasticSearch client.
9
11
  #
@@ -15,55 +17,64 @@ class ElasticSearch::Client
15
17
  # :cluster => "clustername" - the cluster name to use
16
18
  # :node_name => "node_name" - the node name to use when joining the cluster
17
19
  def initialize(options={})
18
- builder = org.elasticsearch.node.NodeBuilder.nodeBuilder
19
- builder.client(true)
20
+ builder = org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder
21
+ builder.put("node.client", true)
20
22
 
21
23
  # The client doesn't need to serve http
22
- builder.settings.put("http.enabled", false)
23
-
24
- case options[:type]
25
- when :local
26
- builder.local(true)
27
- @node = builder.node
28
- @client = @node.client
29
- when :transport
30
- # TODO(sissel): Support transport client
31
- else
32
- # Use unicast discovery a host is given
33
- if !options[:host].nil?
34
- port = (options[:port] or "9300")
35
- builder.settings.put("discovery.zen.ping.multicast.enabled", false)
36
- if port =~ /^\d+-\d+$/
37
- # port ranges are 'host[port1-port2]' according to
38
- # http://www.elasticsearch.org/guide/reference/modules/discovery/zen/
39
- # However, it seems to only query the first port.
40
- # So generate our own list of unicast hosts to scan.
41
- range = Range.new(*port.split("-"))
42
- hosts = range.collect { |p| "#{options[:host]}:#{p}" }.join(",")
43
- builder.settings.put("discovery.zen.ping.unicast.hosts", hosts)
44
- else
45
- # only one port, not a range.
46
- puts "PORT SETTINGS #{options[:host]}:#{port}"
47
- builder.settings.put("discovery.zen.ping.unicast.hosts",
48
- "#{options[:host]}:#{port}")
49
- end
24
+ builder.put("http.enabled", false)
25
+
26
+ # Use unicast discovery a host is given
27
+ if !options[:host].nil?
28
+ port = (options[:port] or "9300")
29
+ builder.put("discovery.zen.ping.multicast.enabled", false)
30
+ if port =~ /^\d+-\d+$/
31
+ # port ranges are 'host[port1-port2]' according to
32
+ # http://www.elasticsearch.org/guide/reference/modules/discovery/zen/
33
+ # However, it seems to only query the first port.
34
+ # So generate our own list of unicast hosts to scan.
35
+ range = Range.new(*port.split("-"))
36
+ hosts = range.collect { |p| "#{options[:host]}:#{p}" }.join(",")
37
+ builder.put("discovery.zen.ping.unicast.hosts", hosts)
38
+ else
39
+ # only one port, not a range.
40
+ puts "PORT SETTINGS #{options[:host]}:#{port}"
41
+ builder.put("discovery.zen.ping.unicast.hosts",
42
+ "#{options[:host]}:#{port}")
50
43
  end
44
+ end
51
45
 
52
- if options[:bind_host]
53
- builder.settings.put('network.host', options[:bind_host])
54
- end
46
+ if options[:bind_host]
47
+ builder.put('network.host', options[:bind_host])
48
+ end
55
49
 
56
- if options[:node_name]
57
- builder.settings.put('node.name', options[:node_name])
58
- end
50
+ if options[:bind_port]
51
+ builder.put('transport.tcp.port', options[:bind_port])
52
+ end
59
53
 
60
- if !options[:cluster].nil?
61
- builder.clusterName(options[:cluster])
62
- end
63
- @node = builder.node
64
- @client = @node.client
54
+ if options[:node_name]
55
+ builder.put('node.name', options[:node_name])
56
+ end
57
+
58
+ if !options[:cluster].nil?
59
+ builder.put('cluster.name', options[:cluster])
65
60
  end
66
61
 
62
+ case options[:type]
63
+ when :transport
64
+ @client = org.elasticsearch.client.transport.TransportClient.new(builder.build)
65
+ if options[:host]
66
+ @client.addTransportAddress(
67
+ org.elasticsearch.common.transport.InetSocketTransportAddress.new(
68
+ options[:host], options[:port] || 9300
69
+ )
70
+ )
71
+ else
72
+ raise ConfigurationError, "When using a transport client, you must give a :host setting to ElasticSearch::Client.new. Otherwise, I don't know what elasticsearch servers talk to."
73
+ end
74
+ else
75
+ nodebuilder = org.elasticsearch.node.NodeBuilder.nodeBuilder
76
+ @client = nodebuilder.settings(builder).node.client
77
+ end
67
78
  end # def initialize
68
79
 
69
80
  # Get a new BulkRequest for sending multiple updates to elasticsearch in one
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
5
- prerelease:
4
+ version: 0.0.16
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jordan Sissel
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-05 00:00:00.000000000 Z
11
+ date: 2013-12-04 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: ! '...'
13
+ description: '...'
15
14
  email:
16
15
  - jls@semicomplete.com
17
16
  executables: []
@@ -20,38 +19,37 @@ extra_rdoc_files: []
20
19
  files:
21
20
  - lib/jruby-elasticsearch.rb
22
21
  - lib/jruby-elasticsearch/indexrequest.rb
23
- - lib/jruby-elasticsearch/searchrequest.rb
24
- - lib/jruby-elasticsearch/actionlistener.rb
25
- - lib/jruby-elasticsearch/namespace.rb
26
22
  - lib/jruby-elasticsearch/client.rb
23
+ - lib/jruby-elasticsearch/namespace.rb
27
24
  - lib/jruby-elasticsearch/request.rb
28
25
  - lib/jruby-elasticsearch/bulkstream.rb
29
26
  - lib/jruby-elasticsearch/bulkrequest.rb
27
+ - lib/jruby-elasticsearch/searchrequest.rb
28
+ - lib/jruby-elasticsearch/actionlistener.rb
30
29
  - test/test_integration.rb
31
30
  homepage: https://github.com/jordansissel/jruby-elasticsearch
32
31
  licenses:
33
32
  - Apache License (2.0)
34
- post_install_message:
33
+ metadata: {}
34
+ post_install_message:
35
35
  rdoc_options: []
36
36
  require_paths:
37
37
  - lib
38
38
  - lib
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
40
  requirements:
42
- - - ! '>='
41
+ - - '>='
43
42
  - !ruby/object:Gem::Version
44
43
  version: '0'
45
44
  required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
45
  requirements:
48
- - - ! '>='
46
+ - - '>='
49
47
  - !ruby/object:Gem::Version
50
48
  version: '0'
51
49
  requirements: []
52
- rubyforge_project:
53
- rubygems_version: 1.8.25
54
- signing_key:
55
- specification_version: 3
50
+ rubyforge_project:
51
+ rubygems_version: 2.1.9
52
+ signing_key:
53
+ specification_version: 4
56
54
  summary: JRuby API for ElasticSearch using the native ES Java API
57
55
  test_files: []