arelastic 0.4.5 → 0.4.6

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: 461f0c1c4638378978028848fa4b076be47c2e2f
4
- data.tar.gz: 08a45801e8a532840076b49315029a4984ba0632
3
+ metadata.gz: 70bfaded4af81b93d4ab0548c586a128a790a794
4
+ data.tar.gz: cadf4637b3c585aa297ded7ada84535c8455911f
5
5
  SHA512:
6
- metadata.gz: 80d59ba50365fb2902826794e215114d6c28b93d1772328aba566ff18921665f83ec76865863febdda8a7d5e6c0b173a98af2e2cc30e5bdbf68113997c829567
7
- data.tar.gz: 6c6d9e6b38e7d1717a50a1850aa94f8d4796434f7ada756deaf380e9830093a0a8135fc13aafea999571283f3bdc56d4bc13495a9b93c3cc933224cf41fa0753
6
+ metadata.gz: 336c9c1902878d897cfb09d2ca0fdcdbe5e02c6241e6c15de160a3727868160f5102f9ef3f00d174e3df43c26477e26e705bd07a021cbdc746173d8171cf8a51
7
+ data.tar.gz: ef592219177802e984bc79c0cc3378e2aaa230fa089503ea616f3bbb69677530c2a9200f0175bffbe483ce5ce0ec0286969001f1fc8e5eee921acf3162a3389c
@@ -2,4 +2,5 @@ require 'arelastic/facets/facet'
2
2
 
3
3
  require 'arelastic/facets/histogram'
4
4
  require 'arelastic/facets/range'
5
- require 'arelastic/facets/terms'
5
+ require 'arelastic/facets/terms'
6
+ require 'arelastic/facets/nested'
@@ -1,6 +1,9 @@
1
1
  module Arelastic
2
2
  module Facets
3
3
  class Facet < Arelastic::Nodes::Node
4
+ def nested path
5
+ Facets::Nested.new path, self
6
+ end
4
7
  end
5
8
  end
6
9
  end
@@ -0,0 +1,9 @@
1
+ module Arelastic
2
+ module Facets
3
+ class Nested < Struct.new :path, :facet
4
+ def as_elastic
5
+ facet.as_elastic.merge("nested" => path)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -12,6 +12,10 @@ module Arelastic
12
12
  def negate
13
13
  Arelastic::Filters::Not.new self
14
14
  end
15
+
16
+ def nested path
17
+ Arelastic::Filters::Nested.new path, self
18
+ end
15
19
  end
16
20
  end
17
21
  end
@@ -13,6 +13,10 @@ module Arelastic
13
13
  end
14
14
  end
15
15
 
16
+ def as_elastic
17
+ {}
18
+ end
19
+
16
20
  def ==(other)
17
21
  as_elastic == other.as_elastic
18
22
  end
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+
3
+ class Arelastic::Builders::FacetTest < MiniTest::Unit::TestCase
4
+ def test_terms
5
+ expected = {"name"=>{"terms"=>{"field"=>"term"}}}
6
+ actual = Arelastic::Builders::Facet['name'].terms('term').as_elastic
7
+ assert_equal expected, actual
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ require 'helper'
2
+
3
+ class Arelastic::Facets::FacetTest < MiniTest::Unit::TestCase
4
+ def test_nested
5
+ facet = Arelastic::Facets::Facet.new
6
+ expected = {
7
+ "nested" => "links"
8
+ }
9
+
10
+ nested = facet.nested "links"
11
+
12
+ assert_equal expected, nested.as_elastic
13
+ end
14
+
15
+ def test_nested_terms
16
+ facet = Arelastic::Facets::Terms.new('foo', 'links.name', "size" => 10)
17
+ expected = {
18
+ "foo" => {
19
+ "terms" => {
20
+ "field" => "links.name",
21
+ "size" => 10,
22
+ }
23
+ },
24
+ "nested" => "links"
25
+ }
26
+
27
+ nested = facet.nested "links"
28
+
29
+ assert_equal expected, nested.as_elastic
30
+ end
31
+ end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Facets::TermsTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Facets::HistogramTest < MiniTest::Unit::TestCase
4
4
  def test_as_elastic
5
5
  facet = Arelastic::Facets::Histogram.new('histo', "field" => "field_name", "interval" => 100)
6
6
  expected = {
@@ -27,4 +27,13 @@ class Arelastic::FilterTest < MiniTest::Unit::TestCase
27
27
  assert negated_filter.is_a?(Arelastic::Filters::Not)
28
28
  assert_equal filter, negated_filter.expr
29
29
  end
30
+
31
+ def test_nested
32
+ filter = Arelastic::Filters::Term.new('foo', 'bar').nested('links')
33
+
34
+ nested_filter = filter.nested 'links'
35
+
36
+ assert nested_filter.is_a?(Arelastic::Filters::Nested)
37
+ assert_equal filter, nested_filter.expr
38
+ end
30
39
  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.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Higgins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-04 00:00:00.000000000 Z
11
+ date: 2013-10-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Build Elastic Search queries with objects
14
14
  email: developer@matthewhiggins.com
@@ -30,6 +30,7 @@ files:
30
30
  - lib/arelastic/builders.rb
31
31
  - lib/arelastic/facets/facet.rb
32
32
  - lib/arelastic/facets/histogram.rb
33
+ - lib/arelastic/facets/nested.rb
33
34
  - lib/arelastic/facets/range.rb
34
35
  - lib/arelastic/facets/terms.rb
35
36
  - lib/arelastic/facets.rb
@@ -91,11 +92,13 @@ files:
91
92
  - test/arelastic/arities/binary_test.rb
92
93
  - test/arelastic/arities/polyadic_test.rb
93
94
  - test/arelastic/arities/unary_test.rb
95
+ - test/arelastic/builders/facet_test.rb
94
96
  - test/arelastic/builders/filter_test.rb
95
97
  - test/arelastic/builders/mapping_test.rb
96
98
  - test/arelastic/builders/query_test.rb
97
99
  - test/arelastic/builders/search_test.rb
98
100
  - test/arelastic/builders/sort_test.rb
101
+ - test/arelastic/facets/facet_test.rb
99
102
  - test/arelastic/facets/histogram_test.rb
100
103
  - test/arelastic/facets/terms_test.rb
101
104
  - test/arelastic/filters/exists_test.rb
@@ -143,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
146
  version: 1.8.11
144
147
  requirements: []
145
148
  rubyforge_project:
146
- rubygems_version: 2.0.2
149
+ rubygems_version: 2.0.3
147
150
  signing_key:
148
151
  specification_version: 4
149
152
  summary: Elastic Search query builder