jruby-elasticsearch 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jruby-elasticsearch/client.rb +14 -2
- data/lib/jruby-elasticsearch/searchrequest.rb +22 -6
- metadata +23 -23
@@ -4,8 +4,20 @@ require "jruby-elasticsearch/indexrequest"
|
|
4
4
|
require "jruby-elasticsearch/searchrequest"
|
5
5
|
|
6
6
|
class ElasticSearch::Client
|
7
|
-
def initialize
|
8
|
-
|
7
|
+
def initialize(options={})
|
8
|
+
builder = org.elasticsearch.node.NodeBuilder.nodeBuilder
|
9
|
+
builder.client(true)
|
10
|
+
|
11
|
+
if !options[:host].nil?
|
12
|
+
port = (options[:port] or "9200")
|
13
|
+
builder.settings.put("es.transport.tcp.port", port)
|
14
|
+
end
|
15
|
+
|
16
|
+
if !options[:cluster].nil?
|
17
|
+
builder.clusterName(options[:cluster])
|
18
|
+
end
|
19
|
+
|
20
|
+
@node = builder.node
|
9
21
|
@client = @node.client
|
10
22
|
end # def initialize
|
11
23
|
|
@@ -32,8 +32,7 @@ class ElasticSearch::SearchRequest < ElasticSearch::Request
|
|
32
32
|
public
|
33
33
|
def execute(&block)
|
34
34
|
use_callback(&block) if block_given?
|
35
|
-
@prep.setIndices(@indeces)
|
36
|
-
|
35
|
+
@prep.setIndices(@indeces.to_java(:String))
|
37
36
|
action = @prep.execute(@handler)
|
38
37
|
return action
|
39
38
|
end # def execute
|
@@ -42,6 +41,7 @@ class ElasticSearch::SearchRequest < ElasticSearch::Request
|
|
42
41
|
# Returns an org.elasticsearch.action.search.SearchResponse
|
43
42
|
public
|
44
43
|
def execute!
|
44
|
+
@prep.setIndices(@indeces.to_java(:String))
|
45
45
|
return @prep.execute.actionGet()
|
46
46
|
end # def execute!
|
47
47
|
|
@@ -60,9 +60,20 @@ class ElasticSearch::SearchRequest < ElasticSearch::Request
|
|
60
60
|
end # def sort
|
61
61
|
|
62
62
|
public
|
63
|
-
def query(query_string)
|
63
|
+
def query(query_string, default_operator=:and)
|
64
64
|
# TODO(sissel): allow doing other queries and such.
|
65
65
|
qbuilder = org.elasticsearch.index.query.xcontent.QueryStringQueryBuilder.new(query_string)
|
66
|
+
|
67
|
+
operator = org.elasticsearch.index.query.xcontent.QueryStringQueryBuilder::Operator
|
68
|
+
case default_operator
|
69
|
+
when :and
|
70
|
+
qbuilder.defaultOperator(operator::AND)
|
71
|
+
when :or
|
72
|
+
qbuilder.defaultOperator(operator::OR)
|
73
|
+
else
|
74
|
+
raise "Unknown default operator '#{default_operator.inspect}'"
|
75
|
+
end
|
76
|
+
|
66
77
|
@prep.setQuery(qbuilder)
|
67
78
|
return self
|
68
79
|
end # def query
|
@@ -83,14 +94,19 @@ class ElasticSearch::SearchRequest < ElasticSearch::Request
|
|
83
94
|
end # def histogram
|
84
95
|
|
85
96
|
public
|
86
|
-
def
|
87
|
-
@prep.setSize(
|
97
|
+
def size(s)
|
98
|
+
@prep.setSize(s)
|
88
99
|
return self
|
89
100
|
end
|
101
|
+
alias :count :size
|
102
|
+
alias :limit :size
|
90
103
|
|
91
104
|
public
|
92
|
-
def
|
105
|
+
def from(from)
|
93
106
|
@prep.setFrom(from)
|
94
107
|
return self
|
95
108
|
end
|
109
|
+
alias :offset :from
|
110
|
+
alias :offset :from
|
111
|
+
|
96
112
|
end # class ElasticSearch::SearchRequest
|
metadata
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
name: jruby-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Jordan Sissel
|
8
|
+
- Jordan Sissel
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-27 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
17
17
|
description: ...
|
18
18
|
email:
|
19
|
-
- jls@semicomplete.com
|
19
|
+
- jls@semicomplete.com
|
20
20
|
executables: []
|
21
21
|
|
22
22
|
extensions: []
|
@@ -24,41 +24,41 @@ extensions: []
|
|
24
24
|
extra_rdoc_files: []
|
25
25
|
|
26
26
|
files:
|
27
|
-
- lib/jruby-elasticsearch.rb
|
28
|
-
- lib/jruby-elasticsearch/searchrequest.rb
|
29
|
-
- lib/jruby-elasticsearch/namespace.rb
|
30
|
-
- lib/jruby-elasticsearch/bulkrequest.rb
|
31
|
-
- lib/jruby-elasticsearch/actionlistener.rb
|
32
|
-
- lib/jruby-elasticsearch/request.rb
|
33
|
-
- lib/jruby-elasticsearch/indexrequest.rb
|
34
|
-
- lib/jruby-elasticsearch/client.rb
|
35
|
-
- lib/jruby-elasticsearch/bulkstream.rb
|
27
|
+
- lib/jruby-elasticsearch.rb
|
28
|
+
- lib/jruby-elasticsearch/searchrequest.rb
|
29
|
+
- lib/jruby-elasticsearch/namespace.rb
|
30
|
+
- lib/jruby-elasticsearch/bulkrequest.rb
|
31
|
+
- lib/jruby-elasticsearch/actionlistener.rb
|
32
|
+
- lib/jruby-elasticsearch/request.rb
|
33
|
+
- lib/jruby-elasticsearch/indexrequest.rb
|
34
|
+
- lib/jruby-elasticsearch/client.rb
|
35
|
+
- lib/jruby-elasticsearch/bulkstream.rb
|
36
36
|
has_rdoc: true
|
37
37
|
homepage: https://github.com/jordansissel/jruby-elasticsearch
|
38
38
|
licenses:
|
39
|
-
- Apache License (2.0)
|
39
|
+
- Apache License (2.0)
|
40
40
|
post_install_message:
|
41
41
|
rdoc_options: []
|
42
42
|
|
43
43
|
require_paths:
|
44
|
-
- lib
|
45
|
-
- lib
|
44
|
+
- lib
|
45
|
+
- lib
|
46
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
47
|
none: false
|
48
48
|
requirements:
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
58
|
requirements: []
|
59
59
|
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.
|
61
|
+
rubygems_version: 1.5.1
|
62
62
|
signing_key:
|
63
63
|
specification_version: 3
|
64
64
|
summary: JRuby API for ElasticSearch using the native ES Java API
|