elasticsearch-model 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2Y1ZDVlOWEyODBjYzg3MmFiYjNmOTZjY2I2YTJmMjIxYzkwN2I1OA==
4
+ YzQ5M2Q0YTQyMWFiNTY5OGIwNzYyMTA2NTkzOGFmNDczZWQzZjQ4Mg==
5
5
  data.tar.gz: !binary |-
6
- NTIyNTFhZDc3MTQ3YTdiMDlmMmYwZmYxN2VjZmIyOTYyNzlhMWY1Yw==
6
+ N2QyZDk1ODYzYjJlY2E3MGY0ZGNlNmFlZDBkMGYzMTk0NzdlMTlmOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmE4MjU1N2UwMmYwNTJiMzM5ZjdlOWM4ZGI0NzI0NzJkYTc0YjA0OTM2M2Q5
10
- MGUwZDBmNzFhMDg2MGQ1NTk1N2U0YmVmOWY4MTI0NGVlMzcwYjNhNjU5MzE3
11
- OWRkYTBmNTAxZGYwOTM1MWQ5Mjc2MDU2ZTUwMDIyOTY3NTcwMmM=
9
+ NGI1ZTM1ODZhYmY1NmVhZmYxYTRjNjRkNTMyYjYxOWY5MzZhY2JkYTlmOWY1
10
+ ZTlhMWI1NTkwOWNlYWVjNWU3ZWQxZTM3NWQ5MDIyZmUxNzRlYjJjNzk0Mjk4
11
+ MzU2OTU3NmQzNjRjYzNkZmQ1MmI3MTdmZjAxYjlmYWY3MWEzYWY=
12
12
  data.tar.gz: !binary |-
13
- ZTUzYzliYmU4NjcxYTFmYWQyMDA2MGE1ZWYwZDhhMmRiMTI3NzlkYjJhNWI3
14
- Y2ExNzY3Mzc1NGM4MmQwZWM1MDEzZDlhMjQyYmViN2ZjNTg1NTJlZWE0NmRm
15
- ZTA1ODRhOWQ1OTUxMWY4YjllZGE3OWQwNzFmMDM5ZDMzNmZkOTg=
13
+ Y2ZjZGM0MGY4OWFhMzZkNmI0NTU4YTlhYzkzNGZmN2FhNGUxZDg2N2NkOGQ3
14
+ ZjM2YjIzNTYxODk2MmJjYWViZmU2NGI5YWI0NjBhNGMyOThiYWVlOTRiYjI5
15
+ ZjUzYWNlNDZhMWM4N2MwYjE3ZmMwMDBiNzVkOTNmNTEwMTJmOTc=
@@ -27,7 +27,9 @@ module Elasticsearch
27
27
  # @return [Hash]
28
28
  #
29
29
  def response
30
- @response ||= search.execute!
30
+ @response ||= begin
31
+ Hashie::Mash.new(search.execute!)
32
+ end
31
33
  end
32
34
 
33
35
  # Returns the collection of "hits" from Elasticsearch
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Model
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -164,6 +164,14 @@ module Elasticsearch
164
164
  assert_equal 'Testing Coding', response.records.order('title DESC').first.title
165
165
  end
166
166
  end
167
+
168
+ should "allow dot access to response" do
169
+ response = Article.search query: { match: { title: { query: 'test' } } },
170
+ aggregations: { dates: { date_histogram: { field: 'created_at', interval: 'hour' } } }
171
+
172
+ response.response.respond_to?(:aggregations)
173
+ assert_equal 2, response.response.aggregations.dates.buckets.first.doc_count
174
+ end
167
175
  end
168
176
 
169
177
  end
@@ -25,6 +25,16 @@ class Elasticsearch::Model::ResponseTest < Test::Unit::TestCase
25
25
  assert_equal 'OK', response.shards.one
26
26
  end
27
27
 
28
+ should "wrap the raw Hash response in Hashie::Mash" do
29
+ @search = Elasticsearch::Model::Searching::SearchRequest.new OriginClass, '*'
30
+ @search.stubs(:execute!).returns({'hits' => { 'hits' => [] }, 'aggregations' => { 'dates' => 'FOO' }})
31
+
32
+ response = Elasticsearch::Model::Response::Response.new OriginClass, @search
33
+
34
+ assert_respond_to response.response, :aggregations
35
+ assert_equal 'FOO', response.response.aggregations.dates
36
+ end
37
+
28
38
  should "load and access the results" do
29
39
  @search.expects(:execute!).returns(RESPONSE)
30
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch