arelastic 0.8.1 → 0.9.0

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: 8edf892187c4bc1b1dfd20957cb7f906a174e477
4
- data.tar.gz: f70671331e9a01954dae642a81b43536c17566aa
3
+ metadata.gz: 7ed83fdd7af7f94209a516bc4438b0eabdf384cd
4
+ data.tar.gz: 899e033e443cfd575043fe6d937f18c15cc63ef5
5
5
  SHA512:
6
- metadata.gz: 5d3950ddc9d39032578070a19a24df1674fe1f6ca52ae94e5d04d421aa8b86f71b75f233e32f1382a6cb14069830b1e135da5665e7e9a6a12ef8681c5b6e0e3d
7
- data.tar.gz: 3e0fee651967a41f0de510d2d5fdcde18d5aa33a058f59d781dca74fc9981e10a01cdc27e07a7045331b0b652366dab1b11612b29351f208eb4476eaff4e5f7f
6
+ metadata.gz: dd9786cc2bc4e10fe3c783cd807845321c35632a40d0a696f6a0f7fbb479e96410228c3fc004b4be8dca68b29225d7d333947f2baa13e94b2123622d029cb654
7
+ data.tar.gz: 836bce0d0430f3338ac5ff4ab02b72c135770648ed0da4d2e8e338ef334bbaeddaa575d9617e99282b4463b92de07dd74c89b830d0642760ea91a409744ac729
data/README.md ADDED
@@ -0,0 +1 @@
1
+ [![Travis](https://secure.travis-ci.org/matthuhiggins/arelastic.png?rvm=1.9.3)](http://travis-ci.org/matthuhiggins/arelastic) [![Code Climate](https://codeclimate.com/github/matthuhiggins/arelastic/badges/gpa.svg)](https://codeclimate.com/github/matthuhiggins/arelastic)
@@ -7,12 +7,12 @@ module Arelastic
7
7
  end
8
8
  end
9
9
 
10
- def terms field, options = {}
11
- Arelastic::Facets::Terms.new name, field, options
10
+ def terms options = {}
11
+ Arelastic::Aggregations::Terms.new name, options
12
12
  end
13
13
 
14
14
  def histogram options
15
- Arelastic::Facets::Histogram.new name, options
15
+ Arelastic::Aggregations::Histogram.new name, options
16
16
  end
17
17
  end
18
18
  end
@@ -14,10 +14,6 @@ module Arelastic
14
14
  Arelastic::Builders::Aggregation
15
15
  end
16
16
 
17
- def facet
18
- Arelastic::Builders::Facet
19
- end
20
-
21
17
  def query
22
18
  Arelastic::Builders::Query
23
19
  end
@@ -1,6 +1,5 @@
1
1
  require 'arelastic/builders/aggregation'
2
2
  require 'arelastic/builders/filter'
3
- require 'arelastic/builders/facet'
4
3
  require 'arelastic/builders/mapping'
5
4
  require 'arelastic/builders/query'
6
5
  require 'arelastic/builders/search'
@@ -14,7 +14,7 @@ module Arelastic
14
14
  end
15
15
 
16
16
  def ==(other)
17
- as_elastic == other.as_elastic
17
+ other.is_a?(Arelastic::Nodes::Node) && as_elastic == other.as_elastic
18
18
  end
19
19
  end
20
20
  end
@@ -1,7 +1,6 @@
1
1
  require 'arelastic/searches/search'
2
2
 
3
3
  require 'arelastic/searches/aggregations'
4
- require 'arelastic/searches/facets'
5
4
  require 'arelastic/searches/filter'
6
5
  require 'arelastic/searches/from'
7
6
  require 'arelastic/searches/query'
data/lib/arelastic.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'arelastic/arities'
2
2
  require 'arelastic/nodes'
3
3
  require 'arelastic/aggregations'
4
- require 'arelastic/facets'
5
4
  require 'arelastic/filters'
6
5
  require 'arelastic/mappings'
7
6
  require 'arelastic/queries'
@@ -2,8 +2,8 @@ require 'helper'
2
2
 
3
3
  class Arelastic::Builders::AggregationTest < Minitest::Test
4
4
  def test_terms
5
- expected = {"name" => {"terms" => {"field" => "term"}}}
6
- actual = Arelastic::Builders::Aggregation['name'].terms('term').as_elastic
5
+ expected = {"name" => {"terms" => {"field" => "color"}}}
6
+ actual = Arelastic::Builders::Aggregation['name'].terms('field' => 'color').as_elastic
7
7
 
8
8
  assert_equal expected, actual
9
9
  end
@@ -13,10 +13,6 @@ class Arelastic::Builders::SearchTest < Minitest::Test
13
13
  assert_equal Arelastic::Builders::Aggregation, Arelastic::Builders::Search.aggregation
14
14
  end
15
15
 
16
- def test_facet
17
- assert_equal Arelastic::Builders::Facet, Arelastic::Builders::Search.facet
18
- end
19
-
20
16
  def test_filter
21
17
  assert_equal Arelastic::Builders::Query, Arelastic::Builders::Search.query
22
18
  end
@@ -14,5 +14,6 @@ class Arelastic::Nodes::NodeTest < Minitest::Test
14
14
 
15
15
  assert_equal node.new('foo'), node.new('foo')
16
16
  refute_equal node.new('foo'), node.new('bar')
17
+ refute_equal node.new('foo'), 'wut'
17
18
  end
18
19
  end
metadata CHANGED
@@ -1,28 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arelastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
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-03-11 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Build Elastic Search queries with objects
14
14
  email: developer@matthewhiggins.com
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files:
18
- - README.rdoc
18
+ - README.md
19
19
  files:
20
- - README.rdoc
20
+ - README.md
21
21
  - lib/arelastic.rb
22
22
  - lib/arelastic/aggregations.rb
23
23
  - lib/arelastic/aggregations/aggregation.rb
24
24
  - lib/arelastic/aggregations/date_histogram.rb
25
25
  - lib/arelastic/aggregations/filter.rb
26
+ - lib/arelastic/aggregations/histogram.rb
26
27
  - lib/arelastic/aggregations/min.rb
27
28
  - lib/arelastic/aggregations/nested.rb
28
29
  - lib/arelastic/aggregations/terms.rb
@@ -32,19 +33,11 @@ files:
32
33
  - lib/arelastic/arities/unary.rb
33
34
  - lib/arelastic/builders.rb
34
35
  - lib/arelastic/builders/aggregation.rb
35
- - lib/arelastic/builders/facet.rb
36
36
  - lib/arelastic/builders/filter.rb
37
37
  - lib/arelastic/builders/mapping.rb
38
38
  - lib/arelastic/builders/query.rb
39
39
  - lib/arelastic/builders/search.rb
40
40
  - lib/arelastic/builders/sort.rb
41
- - lib/arelastic/facets.rb
42
- - lib/arelastic/facets/date_histogram.rb
43
- - lib/arelastic/facets/facet.rb
44
- - lib/arelastic/facets/histogram.rb
45
- - lib/arelastic/facets/nested.rb
46
- - lib/arelastic/facets/range.rb
47
- - lib/arelastic/facets/terms.rb
48
41
  - lib/arelastic/filters.rb
49
42
  - lib/arelastic/filters/and.rb
50
43
  - lib/arelastic/filters/exists.rb
@@ -92,7 +85,6 @@ files:
92
85
  - lib/arelastic/queries/wildcard.rb
93
86
  - lib/arelastic/searches.rb
94
87
  - lib/arelastic/searches/aggregations.rb
95
- - lib/arelastic/searches/facets.rb
96
88
  - lib/arelastic/searches/filter.rb
97
89
  - lib/arelastic/searches/from.rb
98
90
  - lib/arelastic/searches/query.rb
@@ -112,16 +104,11 @@ files:
112
104
  - test/arelastic/arities/polyadic_test.rb
113
105
  - test/arelastic/arities/unary_test.rb
114
106
  - test/arelastic/builders/aggregation_test.rb
115
- - test/arelastic/builders/facet_test.rb
116
107
  - test/arelastic/builders/filter_test.rb
117
108
  - test/arelastic/builders/mapping_test.rb
118
109
  - test/arelastic/builders/query_test.rb
119
110
  - test/arelastic/builders/search_test.rb
120
111
  - test/arelastic/builders/sort_test.rb
121
- - test/arelastic/facets/date_histogram_test.rb
122
- - test/arelastic/facets/facet_test.rb
123
- - test/arelastic/facets/histogram_test.rb
124
- - test/arelastic/facets/terms_test.rb
125
112
  - test/arelastic/filters/exists_test.rb
126
113
  - test/arelastic/filters/filter_test.rb
127
114
  - test/arelastic/filters/geo_distance_test.rb
data/README.rdoc DELETED
@@ -1,2 +0,0 @@
1
- = Arelastic
2
- {<img src="https://secure.travis-ci.org/matthuhiggins/arelastic.png?rvm=1.9.3" />}[http://travis-ci.org/matthuhiggins/arelastic]
@@ -1,19 +0,0 @@
1
- module Arelastic
2
- module Builders
3
- class Facet < Struct.new :name
4
- class << self
5
- def [](name)
6
- new(name)
7
- end
8
- end
9
-
10
- def terms field, options = {}
11
- Arelastic::Facets::Terms.new name, field, options
12
- end
13
-
14
- def histogram options
15
- Arelastic::Facets::Histogram.new name, options
16
- end
17
- end
18
- end
19
- end
@@ -1,18 +0,0 @@
1
- module Arelastic
2
- module Facets
3
- class DateHistogram < Arelastic::Facets::Facet
4
- attr_accessor :options
5
-
6
- def initialize name, options
7
- super name
8
- @options = options
9
- end
10
-
11
- def as_elastic_facet
12
- {
13
- "date_histogram" => options
14
- }
15
- end
16
- end
17
- end
18
- end
@@ -1,19 +0,0 @@
1
- module Arelastic
2
- module Facets
3
- class Facet < Arelastic::Nodes::Node
4
- attr_reader :name
5
-
6
- def initialize name
7
- @name = name
8
- end
9
-
10
- def as_elastic
11
- { name => as_elastic_facet }
12
- end
13
-
14
- def nested path
15
- Facets::Nested.new path, self
16
- end
17
- end
18
- end
19
- end
@@ -1,18 +0,0 @@
1
- module Arelastic
2
- module Facets
3
- class Histogram < Arelastic::Facets::Facet
4
- attr_accessor :options
5
-
6
- def initialize name, options
7
- super name
8
- @options = options
9
- end
10
-
11
- def as_elastic_facet
12
- {
13
- "histogram" => options
14
- }
15
- end
16
- end
17
- end
18
- end
@@ -1,17 +0,0 @@
1
- module Arelastic
2
- module Facets
3
- class Nested < Arelastic::Facets::Facet
4
- attr_reader :path, :facet
5
-
6
- def initialize path, facet
7
- super facet.name
8
- @path = path
9
- @facet = facet
10
- end
11
-
12
- def as_elastic_facet
13
- facet.as_elastic_facet.merge("nested" => path)
14
- end
15
- end
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- module Arelastic
2
- module Facets
3
- class Terms < Arelastic::Facets::Facet
4
- attr_accessor :field, :options
5
-
6
- def initialize name, field, options = {}
7
- super name
8
- @field = field
9
- @options = options
10
- end
11
-
12
- def as_elastic_facet
13
- params = {"field" => field}.update(options)
14
-
15
- {
16
- "terms" => params
17
- }
18
- end
19
- end
20
- end
21
- end
@@ -1,7 +0,0 @@
1
- require 'arelastic/facets/facet'
2
-
3
- require 'arelastic/facets/date_histogram'
4
- require 'arelastic/facets/histogram'
5
- require 'arelastic/facets/range'
6
- require 'arelastic/facets/terms'
7
- require 'arelastic/facets/nested'
@@ -1,14 +0,0 @@
1
- module Arelastic
2
- module Searches
3
- class Facets < Arelastic::Searches::Search
4
- attr_accessor :grouping
5
- def initialize facets
6
- @grouping = Arelastic::Nodes::HashGroup.new facets
7
- end
8
-
9
- def as_elastic
10
- { "facets" => convert_to_elastic(grouping) }
11
- end
12
- end
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- require 'helper'
2
-
3
- class Arelastic::Builders::FacetTest < Minitest::Test
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
@@ -1,17 +0,0 @@
1
- require 'helper'
2
-
3
- class Arelastic::Facets::DateHistogramTest < Minitest::Test
4
- def test_as_elastic
5
- facet = Arelastic::Facets::DateHistogram.new('histo', "field" => "field_name", "interval" => "day")
6
- expected = {
7
- "histo" => {
8
- "date_histogram" => {
9
- "field" => "field_name",
10
- "interval" => "day"
11
- }
12
- }
13
- }
14
-
15
- assert_equal expected, facet.as_elastic
16
- end
17
- end
@@ -1,36 +0,0 @@
1
- require 'helper'
2
-
3
- class Arelastic::Facets::FacetTest < Minitest::Test
4
- def test_nested
5
- facet = Class.new(Arelastic::Facets::Facet) do
6
- def as_elastic_facet
7
- {}
8
- end
9
- end.new 'name'
10
-
11
- expected = {
12
- "name" => {"nested" => "links"}
13
- }
14
-
15
- nested = facet.nested "links"
16
-
17
- assert_equal expected, nested.as_elastic
18
- end
19
-
20
- def test_nested_terms
21
- facet = Arelastic::Facets::Terms.new('foo', 'links.name', "size" => 10)
22
- expected = {
23
- "foo" => {
24
- "terms" => {
25
- "field" => "links.name",
26
- "size" => 10,
27
- },
28
- "nested" => "links"
29
- }
30
- }
31
-
32
- nested = facet.nested "links"
33
-
34
- assert_equal expected, nested.as_elastic
35
- end
36
- end
@@ -1,17 +0,0 @@
1
- require 'helper'
2
-
3
- class Arelastic::Facets::HistogramTest < Minitest::Test
4
- def test_as_elastic
5
- facet = Arelastic::Facets::Histogram.new('histo', "field" => "field_name", "interval" => 100)
6
- expected = {
7
- "histo" => {
8
- "histogram" => {
9
- "field" => "field_name",
10
- "interval" => 100
11
- }
12
- }
13
- }
14
-
15
- assert_equal expected, facet.as_elastic
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'helper'
2
-
3
- class Arelastic::Facets::TermsTest < Minitest::Test
4
- def test_as_elastic
5
- facet = Arelastic::Facets::Terms.new('foo', 'tags', "size" => 10)
6
- expected = {
7
- "foo" => {
8
- "terms" => {
9
- "field" => "tags",
10
- "size" => 10,
11
- }
12
- }
13
- }
14
-
15
- assert_equal expected, facet.as_elastic
16
- end
17
- end