sequel-elasticsearch 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ec57146972164d9b3940a06d43f971d27b578db9a851f8ca90b33f6239b4f72
4
- data.tar.gz: 21cc2da346ba2f249956e4b945b8cd4331ef4420eb670efb32ebe387bd3b9676
3
+ metadata.gz: b87c9a8747c0bd243d305af4f02882448d70aa520df3796f2873d01a3f541c20
4
+ data.tar.gz: 60c22bb219e9ff03d2a0d0643e88ee444e13eae054c72bf5d0763b833bfc25ac
5
5
  SHA512:
6
- metadata.gz: d2d560ca5424d915563d586dfc605b6ace4e660283472209a4152464ec165612080afb87d85ece0a1f59ea6884ea4a52f981c961fbb69d574b5f2202930eb936
7
- data.tar.gz: f21cd9634945eb35227d0f65a882486c40ccc4c4c368144cb2978baba18376d7902ab553cd49aeeb01cae2738f3df71546aad756e3ee002890764087f617ee2c
6
+ metadata.gz: 0ef4ffc7a7beb5e2c90a54ec37ab64a5b656880d7ac3246b33772dd26a93339993d2f5fe7df18eff1485c9cae1002477ba7965566e536d1648915e0114d43481
7
+ data.tar.gz: 23937b2f2d737e0b1eddad6348132604b0a99cd220f2bccb8e29d941effb7e42061d8d46b944d259bb4c6238be7103fd253161b7f18fa25678893715959c758f
data/Gemfile.dev CHANGED
@@ -6,4 +6,5 @@ gem 'rspec'
6
6
  gem 'rubocop'
7
7
  gem 'sequel'
8
8
  gem 'simplecov'
9
+ gem 'sqlite3'
9
10
  gem 'webmock'
data/Rakefile CHANGED
@@ -10,3 +10,7 @@ rescue LoadError
10
10
  end
11
11
 
12
12
  task default: :spec
13
+
14
+ desc 'Propose mappings based on a Sequel model'
15
+ task :sequel_mappings do
16
+ end
@@ -0,0 +1,27 @@
1
+ module Sequel
2
+ module Plugins
3
+ module Elasticsearch
4
+ class Result
5
+ include Enumerable
6
+
7
+ attr_reader :results, :scroll_id, :total, :took, :timed_out
8
+
9
+ def initialize(results)
10
+ return unless results && results['hits']
11
+ @results = results
12
+ @scroll_id = results['_scroll_id']
13
+ @total = results['hits']['total']
14
+ @timed_out = results['timed_out']
15
+ @took = results['took']
16
+ end
17
+
18
+ def each
19
+ return [] unless results['hits'] && results['hits']['hits']
20
+ results['hits']['hits'].each { |h| yield h }
21
+ # TODO: Use the scroll id to get more if needed
22
+ # We will need access to the client, somehow...
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  module Sequel
2
2
  module Elasticsearch
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  require 'elasticsearch'
2
+ require 'sequel/plugins/elasticsearch/result'
2
3
 
3
4
  module Sequel
4
5
  module Plugins
@@ -30,7 +31,7 @@ module Sequel
30
31
  type: elasticsearch_type
31
32
  }.merge(opts)
32
33
  query.is_a?(String) ? opts[:q] = query : opts[:body] = query
33
- es_client.search opts
34
+ Result.new es_client.search(opts)
34
35
  end
35
36
 
36
37
  def es(query = '', opts = {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurgens du Toit
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-04 00:00:00.000000000 Z
11
+ date: 2018-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch
@@ -140,6 +140,7 @@ files:
140
140
  - README.md
141
141
  - Rakefile
142
142
  - lib/sequel/plugins/elasticsearch.rb
143
+ - lib/sequel/plugins/elasticsearch/result.rb
143
144
  - lib/sequel/plugins/elasticsearch/version.rb
144
145
  - sequel-elasticsearch.gemspec
145
146
  homepage: https://github.com/jrgns/sequel-elasticsearch
@@ -162,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
163
  version: '0'
163
164
  requirements: []
164
165
  rubyforge_project:
165
- rubygems_version: 2.7.4
166
+ rubygems_version: 2.7.5
166
167
  signing_key:
167
168
  specification_version: 4
168
169
  summary: A plugin for the Sequel gem to sync data to Elasticsearch.