arelastic 0.9.0 → 0.9.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ed83fdd7af7f94209a516bc4438b0eabdf384cd
4
- data.tar.gz: 899e033e443cfd575043fe6d937f18c15cc63ef5
3
+ metadata.gz: 87aa4611a9b69484f792da345e91c2fa81c0f3be
4
+ data.tar.gz: 8163a78df33b8ec32a31afef6c39c676bd4e2432
5
5
  SHA512:
6
- metadata.gz: dd9786cc2bc4e10fe3c783cd807845321c35632a40d0a696f6a0f7fbb479e96410228c3fc004b4be8dca68b29225d7d333947f2baa13e94b2123622d029cb654
7
- data.tar.gz: 836bce0d0430f3338ac5ff4ab02b72c135770648ed0da4d2e8e338ef334bbaeddaa575d9617e99282b4463b92de07dd74c89b830d0642760ea91a409744ac729
6
+ metadata.gz: 5b3f37121f550f07d5f2832266adb731f180ff1212118351ec6acd891bde04568511fb7cc9ebc5126c79ee59a832b2f746ae551ed55c621da4fcf1ed9029e652
7
+ data.tar.gz: 955fe1ee727cc071585c8a6ff7d0b482496cfe8a6f62d4f97fd423e4c3336b88194304316b230a4f795067bc89acdfcc29570f3d5d1f806a9bc4b1dac16f0a16
@@ -1,17 +1,7 @@
1
1
  module Arelastic
2
2
  module Filters
3
3
  class Nested < Arelastic::Filters::Filter
4
- attr_accessor :path, :expr
5
- def initialize(path, expr)
6
- @path = path
7
- @expr = expr
8
- end
9
-
10
- def as_elastic
11
- params = {'path' => path}.update(convert_to_elastic(expr))
12
-
13
- { 'nested' => params }
14
- end
4
+ include Arelastic::Nodes::Nested
15
5
  end
16
6
  end
17
7
  end
@@ -1,2 +1,4 @@
1
1
  require 'arelastic/nodes/node'
2
+
3
+ require 'arelastic/nodes/nested'
2
4
  require 'arelastic/nodes/hash_group'
@@ -0,0 +1,22 @@
1
+ module Arelastic
2
+ module Nodes
3
+ module Nested
4
+ def self.included(klass)
5
+ klass.class_eval do
6
+ attr_accessor :path, :expr
7
+ end
8
+ end
9
+
10
+ def initialize(path, expr)
11
+ @path = path
12
+ @expr = expr
13
+ end
14
+
15
+ def as_elastic
16
+ params = {'path' => path}.update(convert_to_elastic(expr))
17
+
18
+ { 'nested' => params }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -7,6 +7,7 @@ require 'arelastic/queries/filtered'
7
7
  require 'arelastic/queries/match'
8
8
  require 'arelastic/queries/match_all'
9
9
  require 'arelastic/queries/multi_match'
10
+ require 'arelastic/queries/nested'
10
11
  require 'arelastic/queries/prefix'
11
12
  require 'arelastic/queries/query_string'
12
13
  require 'arelastic/queries/terms'
@@ -0,0 +1,7 @@
1
+ module Arelastic
2
+ module Queries
3
+ class Nested < Arelastic::Queries::Query
4
+ include Arelastic::Nodes::Nested
5
+ end
6
+ end
7
+ end
@@ -1,6 +1,9 @@
1
1
  module Arelastic
2
2
  module Queries
3
3
  class Query < Arelastic::Nodes::Node
4
+ def nested path
5
+ Arelastic::Queries::Nested.new path, "query" => self.as_elastic
6
+ end
4
7
  end
5
8
  end
6
9
  end
@@ -1,6 +1,18 @@
1
1
  require 'helper'
2
2
 
3
3
  class Arelastic::Queries::QueryTest < Minitest::Test
4
- def test_as_elastic
4
+ def test_nested
5
+ query = Arelastic::Queries::Term.new('foo', 'bar')
6
+
7
+ nested_query = query.nested 'links'
8
+
9
+ assert nested_query.is_a?(Arelastic::Queries::Nested)
10
+ expected = {
11
+ "nested" => {
12
+ "path" => "links",
13
+ "query" => query.as_elastic
14
+ }
15
+ }
16
+ assert_equal(expected, nested_query.as_elastic)
5
17
  end
6
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arelastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Higgins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-31 00:00:00.000000000 Z
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Build Elastic Search queries with objects
14
14
  email: developer@matthewhiggins.com
@@ -68,6 +68,7 @@ files:
68
68
  - lib/arelastic/mappings/types/string.rb
69
69
  - lib/arelastic/nodes.rb
70
70
  - lib/arelastic/nodes/hash_group.rb
71
+ - lib/arelastic/nodes/nested.rb
71
72
  - lib/arelastic/nodes/node.rb
72
73
  - lib/arelastic/queries.rb
73
74
  - lib/arelastic/queries/bool.rb
@@ -77,6 +78,7 @@ files:
77
78
  - lib/arelastic/queries/match.rb
78
79
  - lib/arelastic/queries/match_all.rb
79
80
  - lib/arelastic/queries/multi_match.rb
81
+ - lib/arelastic/queries/nested.rb
80
82
  - lib/arelastic/queries/prefix.rb
81
83
  - lib/arelastic/queries/query.rb
82
84
  - lib/arelastic/queries/query_string.rb