elasticsearch 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7aaced35f5570173d3b40640e81da0048fd297db
4
+ data.tar.gz: 5b73dea3959463f77c1946701333dec491a886e7
5
+ SHA512:
6
+ metadata.gz: 674c8c0acf0cac33da87d64d2d951a868d4e456af1212c989d288c92ad3caa87a9deaec9ec65748534122fde69fc8b8667252cd5d3d7ded1e44ec10c1ac93d09
7
+ data.tar.gz: af2db288fc1ac2bf96ed820b50941337ee9b1a78ab59f0c101453f0ded37b0b8c40115c1e50060d63fe2316fc0cb4a4cbdabc46bd6c4a3fb42d83d542671b665
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in elasticsearch.gemspec
4
+ gemspec
@@ -0,0 +1,13 @@
1
+ Copyright 2013 Elasticsearch
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,85 @@
1
+ # Elasticsearch
2
+
3
+ The `elasticsearch` library provides a Ruby client and API for [Elasticsearch](http://elasticsearch.org).
4
+
5
+ Features overview:
6
+
7
+ * Pluggable logging and tracing
8
+ * Plugabble connection selection strategies (round-robin, random, custom)
9
+ * Pluggable transport implementation, customizable and extendable
10
+ * Pluggable serializer implementation
11
+ * Request retries and dead connections handling
12
+ * Node reloading (based on cluster state) on errors or on demand
13
+ * Consistent API support for the whole Elasticsearch API
14
+ * Extensive documentation and examples
15
+ * Emphasis on modularity and extendability of both the client and API libraries
16
+
17
+ ## Installation
18
+
19
+ Install the package from [Rubygems](https://rubygems.org):
20
+
21
+ gem install elasticsearch
22
+
23
+ To use an unreleased version, either add it to your `Gemfile` for [Bundler](http://gembundler.com):
24
+
25
+ gem 'elasticsearch', git: 'git://github.com/elasticsearch/elasticsearch-ruby.git'
26
+
27
+ or install it from a source code checkout:
28
+
29
+ git clone https://github.com/elasticsearch/elasticsearch-ruby.git
30
+ cd elasticsearch-ruby/elasticsearch
31
+ bundle install
32
+ rake install
33
+
34
+ ## Usage
35
+
36
+ This library is a wrapper for two separate libraries:
37
+
38
+ * [`elasticsearch-transport`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-transport),
39
+ which provides a Ruby client for connecting to an [Elasticsearch](http://elasticsearch.org) cluster
40
+ * [`elasticsearch-api`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-api),
41
+ which provides a Ruby API for the Elasticsearch RESTful API
42
+
43
+ Install the `elasticsearch` package and use the API directly:
44
+
45
+ ```ruby
46
+ require 'elasticsearch'
47
+
48
+ client = Elasticsearch::Client.new log: true
49
+
50
+ client.cluster.health
51
+
52
+ client.transport.reload_connections!
53
+
54
+ client.search q: 'test'
55
+
56
+ # etc.
57
+ ```
58
+
59
+ Please refer to the specific library documentation for details:
60
+
61
+ * **Client**:
62
+ [[README]](https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-client/README.md)
63
+ [[Documentation]](http://rubydoc.info/gems/elasticsearch-client/file/README.markdown)
64
+
65
+ * **API**:
66
+ [[README]](https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-api/README.md)
67
+ [[Documentation]](http://rubydoc.info/gems/elasticsearch-api/file/README.markdown)
68
+
69
+ ## License
70
+
71
+ This software is licensed under the Apache 2 license, quoted below.
72
+
73
+ Copyright (c) 2013 Elasticsearch <http://www.elasticsearch.org>
74
+
75
+ Licensed under the Apache License, Version 2.0 (the "License");
76
+ you may not use this file except in compliance with the License.
77
+ You may obtain a copy of the License at
78
+
79
+ http://www.apache.org/licenses/LICENSE-2.0
80
+
81
+ Unless required by applicable law or agreed to in writing, software
82
+ distributed under the License is distributed on an "AS IS" BASIS,
83
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
84
+ See the License for the specific language governing permissions and
85
+ limitations under the License.
@@ -0,0 +1,31 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc "Run unit tests"
4
+ task :default => 'test:unit'
5
+ task :test => 'test:unit'
6
+
7
+ # ----- Test tasks ------------------------------------------------------------
8
+
9
+ require 'rake/testtask'
10
+ namespace :test do
11
+
12
+ Rake::TestTask.new(:unit) do |test|
13
+ test.libs << 'lib' << 'test'
14
+ test.test_files = FileList["test/unit/**/*_test.rb"]
15
+ # test.verbose = true
16
+ # test.warning = true
17
+ end
18
+
19
+ Rake::TestTask.new(:integration) do |test|
20
+ test.libs << 'lib' << 'test'
21
+ test.test_files = FileList["test/integration/**/*_test.rb"]
22
+ end
23
+
24
+ end
25
+
26
+ # ----- Documentation tasks ---------------------------------------------------
27
+
28
+ require 'yard'
29
+ YARD::Rake::YardocTask.new(:doc) do |t|
30
+ t.options = %w| --embed-mixins --markup=markdown |
31
+ end
@@ -0,0 +1,45 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'elasticsearch/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "elasticsearch"
8
+ s.version = Elasticsearch::VERSION
9
+ s.authors = ["Karel Minarik"]
10
+ s.email = ["karel.minarik@elasticsearch.org"]
11
+ s.summary = "Ruby integrations for Elasticsearch"
12
+ s.homepage = "http://github.com/elasticsearch/elasticsearch-ruby"
13
+ s.license = "Apache 2"
14
+
15
+ s.files = `git ls-files`.split($/)
16
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+ s.require_paths = ["lib"]
19
+
20
+ s.extra_rdoc_files = [ "README.md", "LICENSE.txt" ]
21
+ s.rdoc_options = [ "--charset=UTF-8" ]
22
+
23
+ s.add_dependency "elasticsearch-transport", '0.0.2'
24
+ s.add_dependency "elasticsearch-api", '0.0.2'
25
+
26
+ s.add_development_dependency "bundler", "> 1"
27
+ s.add_development_dependency "rake"
28
+
29
+ s.add_development_dependency "ansi"
30
+ s.add_development_dependency "shoulda-context"
31
+ s.add_development_dependency "mocha"
32
+ s.add_development_dependency "turn"
33
+ s.add_development_dependency "yard"
34
+ s.add_development_dependency "ruby-prof"
35
+
36
+ if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
37
+ s.add_development_dependency "simplecov"
38
+ s.add_development_dependency "cane"
39
+ s.add_development_dependency "require-prof"
40
+ end
41
+
42
+ s.description = <<-DESC.gsub(/^ /, '')
43
+ Ruby integrations for Elasticsearch (client, API, etc.)
44
+ DESC
45
+ end
@@ -0,0 +1 @@
1
+ require 'elasticsearch'
@@ -0,0 +1,12 @@
1
+ require "elasticsearch/version"
2
+
3
+ require 'elasticsearch/transport'
4
+ require 'elasticsearch/api'
5
+
6
+ module Elasticsearch
7
+ module Transport
8
+ class Client
9
+ include Elasticsearch::API
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Elasticsearch
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,55 @@
1
+ require 'test_helper'
2
+ require 'logger'
3
+
4
+ module Elasticsearch
5
+ module Test
6
+ class ClientIntegrationTest < ::Test::Unit::TestCase
7
+ # startup do
8
+ # Elasticsearch::TestCluster.start if ENV['SERVER'] and not Elasticsearch::TestCluster.running?
9
+ # end
10
+
11
+ context "Elasticsearch client" do
12
+ setup do
13
+ # system "curl -X DELETE http://localhost:9250/_all > /dev/null 2>&1"
14
+
15
+ @logger = Logger.new(STDERR)
16
+ @logger.formatter = proc do |severity, datetime, progname, msg|
17
+ color = case severity
18
+ when /INFO/ then :green
19
+ when /ERROR|WARN|FATAL/ then :red
20
+ when /DEBUG/ then :cyan
21
+ else :white
22
+ end
23
+ ANSI.ansi(severity[0] + ' ', color, :faint) + ANSI.ansi(msg, :white, :faint) + "\n"
24
+ end
25
+
26
+ @client = Elasticsearch::Client.new host: 'localhost:9200', logger: @logger
27
+ end
28
+
29
+ should "perform the API methods" do
30
+ assert_nothing_raised do
31
+ # Index a document
32
+ #
33
+ @client.index index: 'test-index', type: 'test-type', id: '1', body: { title: 'Test' }
34
+
35
+ # Refresh the index
36
+ #
37
+ @client.indices.refresh index: 'test-index'
38
+
39
+ # Search
40
+ #
41
+ response = @client.search index: 'test-index', body: { query: { match: { title: 'test' } } }
42
+
43
+ assert_equal 1, response['hits']['total']
44
+ assert_equal 'Test', response['hits']['hits'][0]['_source']['title']
45
+
46
+ # Delete the index
47
+ #
48
+ @client.indices.delete index: 'test-index'
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,17 @@
1
+ RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
2
+
3
+ if RUBY_1_8
4
+ require 'rubygems'
5
+ gem 'test-unit'
6
+ end
7
+
8
+ require 'simplecov' and SimpleCov.start { add_filter "/test|test_/" } if ENV["COVERAGE"]
9
+
10
+ require 'test/unit'
11
+ require 'shoulda-context'
12
+ require 'mocha/setup'
13
+ require 'turn' unless ENV["TM_FILEPATH"] || ENV["NOTURN"] || RUBY_1_8
14
+
15
+ require 'require-prof' if ENV["REQUIRE_PROF"]
16
+ require 'elasticsearch'
17
+ RequireProf.print_timing_infos if ENV["REQUIRE_PROF"]
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class WrapperGemTest < ::Test::Unit::TestCase
6
+
7
+ context "Wrapper gem" do
8
+
9
+ should "require all neccessary subgems" do
10
+ assert defined? Elasticsearch::Client
11
+ assert defined? Elasticsearch::API
12
+ end
13
+
14
+ should "mix the API into the client" do
15
+ client = Elasticsearch::Client.new
16
+
17
+ assert_respond_to client, :search
18
+ assert_respond_to client, :cluster
19
+ assert_respond_to client, :indices
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,246 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: elasticsearch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Karel Minarik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: elasticsearch-transport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: elasticsearch-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>'
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>'
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ansi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: shoulda-context
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mocha
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: turn
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: ruby-prof
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: cane
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: require-prof
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description: |
196
+ Ruby integrations for Elasticsearch (client, API, etc.)
197
+ email:
198
+ - karel.minarik@elasticsearch.org
199
+ executables: []
200
+ extensions: []
201
+ extra_rdoc_files:
202
+ - README.md
203
+ - LICENSE.txt
204
+ files:
205
+ - .gitignore
206
+ - Gemfile
207
+ - LICENSE.txt
208
+ - README.md
209
+ - Rakefile
210
+ - elasticsearch.gemspec
211
+ - lib/elasticsearch-ruby.rb
212
+ - lib/elasticsearch.rb
213
+ - lib/elasticsearch/version.rb
214
+ - test/integration/client_integration_test.rb
215
+ - test/test_helper.rb
216
+ - test/unit/wrapper_gem_test.rb
217
+ homepage: http://github.com/elasticsearch/elasticsearch-ruby
218
+ licenses:
219
+ - Apache 2
220
+ metadata: {}
221
+ post_install_message:
222
+ rdoc_options:
223
+ - --charset=UTF-8
224
+ require_paths:
225
+ - lib
226
+ required_ruby_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - '>='
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ required_rubygems_version: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - '>='
234
+ - !ruby/object:Gem::Version
235
+ version: '0'
236
+ requirements: []
237
+ rubyforge_project:
238
+ rubygems_version: 2.0.0
239
+ signing_key:
240
+ specification_version: 4
241
+ summary: Ruby integrations for Elasticsearch
242
+ test_files:
243
+ - test/integration/client_integration_test.rb
244
+ - test/test_helper.rb
245
+ - test/unit/wrapper_gem_test.rb
246
+ has_rdoc: