arelastic 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arelastic/aggregations.rb +2 -0
  3. data/lib/arelastic/aggregations/aggregation.rb +4 -0
  4. data/lib/arelastic/aggregations/date_histogram.rb +9 -0
  5. data/lib/arelastic/aggregations/min.rb +2 -9
  6. data/test/arelastic/aggregations/aggregation_test.rb +22 -0
  7. data/test/arelastic/aggregations/date_histogram_test.rb +17 -0
  8. data/test/arelastic/aggregations/filter_test.rb +1 -1
  9. data/test/arelastic/aggregations/nested_test.rb +6 -1
  10. data/test/arelastic/aggregations/terms_test.rb +1 -1
  11. data/test/arelastic/arities/binary_test.rb +1 -1
  12. data/test/arelastic/arities/polyadic_test.rb +1 -1
  13. data/test/arelastic/arities/unary_test.rb +1 -1
  14. data/test/arelastic/builders/aggregation_test.rb +1 -1
  15. data/test/arelastic/builders/facet_test.rb +1 -1
  16. data/test/arelastic/builders/filter_test.rb +1 -1
  17. data/test/arelastic/builders/mapping_test.rb +1 -1
  18. data/test/arelastic/builders/query_test.rb +1 -1
  19. data/test/arelastic/builders/search_test.rb +1 -1
  20. data/test/arelastic/builders/sort_test.rb +1 -1
  21. data/test/arelastic/facets/date_histogram_test.rb +1 -1
  22. data/test/arelastic/facets/facet_test.rb +1 -1
  23. data/test/arelastic/facets/histogram_test.rb +1 -1
  24. data/test/arelastic/facets/terms_test.rb +1 -1
  25. data/test/arelastic/filters/exists_test.rb +1 -1
  26. data/test/arelastic/filters/filter_test.rb +1 -1
  27. data/test/arelastic/filters/geo_distance_test.rb +1 -1
  28. data/test/arelastic/filters/has_child_test.rb +1 -1
  29. data/test/arelastic/filters/ids_test.rb +1 -1
  30. data/test/arelastic/filters/match_all_test.rb +1 -1
  31. data/test/arelastic/filters/missing_test.rb +1 -1
  32. data/test/arelastic/filters/nested_test.rb +1 -1
  33. data/test/arelastic/filters/not_test.rb +1 -1
  34. data/test/arelastic/filters/query_test.rb +1 -1
  35. data/test/arelastic/filters/script_test.rb +1 -1
  36. data/test/arelastic/mappings/types/binary_test.rb +1 -1
  37. data/test/arelastic/mappings/types/multi_field_test.rb +1 -1
  38. data/test/arelastic/mappings/types/string_test.rb +1 -1
  39. data/test/arelastic/nodes/node_test.rb +1 -1
  40. data/test/arelastic/queries/bool_test.rb +1 -1
  41. data/test/arelastic/queries/filtered_test.rb +1 -1
  42. data/test/arelastic/queries/match_all_test.rb +1 -1
  43. data/test/arelastic/queries/multi_match_test.rb +1 -1
  44. data/test/arelastic/queries/query_string_test.rb +1 -1
  45. data/test/arelastic/queries/query_test.rb +1 -1
  46. data/test/arelastic/queries/wildcard_test.rb +1 -1
  47. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3dfdb1c53a2b4a1212dc4dc8c0bdeba81ae481f
4
- data.tar.gz: b137778aaf23ff83245097e52bb334a443bbc465
3
+ metadata.gz: 8edf892187c4bc1b1dfd20957cb7f906a174e477
4
+ data.tar.gz: f70671331e9a01954dae642a81b43536c17566aa
5
5
  SHA512:
6
- metadata.gz: 92ba970d8aa6fe7504d7746b76d3549d6529a295a3f863b6343ad5067035db3f869c41b69583fb16f4e440b61b21a641f892334d47ac19d884cb7a8e76e4faa5
7
- data.tar.gz: 1ca4a168ca68149c6ebea89396672c1e5496c0a584ce87884b319378c0a3600fc5fd03268fd67a13699c63f80af2f0ffffe480e5519ab1a4cf948819908e7822
6
+ metadata.gz: 5d3950ddc9d39032578070a19a24df1674fe1f6ca52ae94e5d04d421aa8b86f71b75f233e32f1382a6cb14069830b1e135da5665e7e9a6a12ef8681c5b6e0e3d
7
+ data.tar.gz: 3e0fee651967a41f0de510d2d5fdcde18d5aa33a058f59d781dca74fc9981e10a01cdc27e07a7045331b0b652366dab1b11612b29351f208eb4476eaff4e5f7f
@@ -1,5 +1,7 @@
1
1
  require 'arelastic/aggregations/aggregation'
2
2
 
3
+ require 'arelastic/aggregations/date_histogram'
3
4
  require 'arelastic/aggregations/filter'
5
+ require 'arelastic/aggregations/min'
4
6
  require 'arelastic/aggregations/nested'
5
7
  require 'arelastic/aggregations/terms'
@@ -12,6 +12,10 @@ module Arelastic
12
12
  {name => as_elastic_aggregation}
13
13
  end
14
14
 
15
+ def nested(path)
16
+ Arelastic::Aggregations::Nested.new(name, path, [self])
17
+ end
18
+
15
19
  def as_elastic_aggregation
16
20
  raise 'not implemented'
17
21
  end
@@ -0,0 +1,9 @@
1
+ module Arelastic
2
+ module Aggregations
3
+ class DateHistogram < Arelastic::Aggregations::Aggregation
4
+ def as_elastic_aggregation
5
+ {'date_histogram' => options}
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,15 +1,8 @@
1
1
  module Arelastic
2
2
  module Aggregations
3
- class Min < Arelastic::Aggs::Aggregation
4
- attr_accessor :options
5
-
6
- def initialize name, options
7
- super name
8
- @options = options
9
- end
10
-
3
+ class Min < Arelastic::Aggregations::Aggregation
11
4
  def as_elastic_aggregation
12
- # {"min" => options}
5
+ {"min" => options}
13
6
  end
14
7
  end
15
8
  end
@@ -0,0 +1,22 @@
1
+ require 'helper'
2
+
3
+ class Arelastic::Aggregations::AggregationTest < Minitest::Test
4
+ def test_nested
5
+ aggregation = Arelastic::Aggregations::Min.new('smallest', 'field' => 'pets.weight').nested('pets')
6
+
7
+ expected = {
8
+ "smallest" => {
9
+ "nested" => {
10
+ "path" => "pets"
11
+ },
12
+ "aggs" => {
13
+ "smallest" => {
14
+ "min" => { "field" => "pets.weight" }
15
+ }
16
+ }
17
+ }
18
+ }
19
+
20
+ assert_equal expected, aggregation.as_elastic
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ require 'helper'
2
+
3
+ class Arelastic::Aggregations::DateHistogramTest < Minitest::Test
4
+ def test_as_elastic
5
+ aggregation = Arelastic::Aggregations::DateHistogram.new('foo', 'field' => 'birthdate', 'interval' => 'month')
6
+
7
+ expected = {
8
+ "foo" => {
9
+ "date_histogram" => {
10
+ "field" => "birthdate",
11
+ "interval" => "month"
12
+ }
13
+ }
14
+ }
15
+ assert_equal expected, aggregation.as_elastic
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Aggregations::TermsTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Aggregations::TermsTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  aggregation = Arelastic::Aggregations::Filter.new('foo', 'exists' => {'field' => 'color'})
6
6
  expected = {
@@ -1,4 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Aggregations::NestedTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Aggregations::NestedTest < Minitest::Test
4
+ def test_as_elastic
5
+ aggregation = Arelastic::Aggregations::Nested.new('favorite', 'movies', [
6
+
7
+ ])
8
+ end
4
9
  end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Aggregations::TermsTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Aggregations::TermsTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  aggregation = Arelastic::Aggregations::Terms.new('foo', 'field' => 'tags', 'size' => 10)
6
6
  expected = {
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Arities::BinaryTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Arities::BinaryTest < Minitest::Test
4
4
  def test_binary
5
5
  node = Class.new(Arelastic::Nodes::Node) do
6
6
  binary 'suffix'
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Arities::PolyadicTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Arities::PolyadicTest < Minitest::Test
4
4
  def test_polyadic
5
5
  expr = Struct.new(:as_elastic)
6
6
  node = Class.new(Arelastic::Nodes::Node) do
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Arities::UnaryTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Arities::UnaryTest < Minitest::Test
4
4
  def test_unary
5
5
  node = Class.new(Arelastic::Nodes::Node) do
6
6
  unary 'unicorn'
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Builders::AggregationTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Builders::AggregationTest < Minitest::Test
4
4
  def test_terms
5
5
  expected = {"name" => {"terms" => {"field" => "term"}}}
6
6
  actual = Arelastic::Builders::Aggregation['name'].terms('term').as_elastic
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Builders::FacetTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Builders::FacetTest < Minitest::Test
4
4
  def test_terms
5
5
  expected = {"name" => {"terms" => {"field" => "term"}}}
6
6
  actual = Arelastic::Builders::Facet['name'].terms('term').as_elastic
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Builders::FilterTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Builders::FilterTest < Minitest::Test
4
4
  def test_ids
5
5
  expected = {"ids" => {"values"=>["5", "6"]}}
6
6
  assert_equal expected, Arelastic::Builders::Filter.ids('5', '6').as_elastic
@@ -1,4 +1,4 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Builders::MappingTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Builders::MappingTest < Minitest::Test
4
4
  end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Builders::QueryTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Builders::QueryTest < Minitest::Test
4
4
  def test_constant_score
5
5
  query = Arelastic::Builders::Query.constant_score({"foo" => "bar"})
6
6
  expected = {"query" => {"constant_score" => {"foo" => "bar"}}}
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Builders::SearchTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Builders::SearchTest < Minitest::Test
4
4
  def test_filter
5
5
  assert_equal Arelastic::Builders::Filter, Arelastic::Builders::Search.filter
6
6
  end
@@ -1,5 +1,5 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Builders::SortTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Builders::SortTest < Minitest::Test
4
4
 
5
5
  end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Facets::DateHistogramTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Facets::DateHistogramTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  facet = Arelastic::Facets::DateHistogram.new('histo', "field" => "field_name", "interval" => "day")
6
6
  expected = {
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Facets::FacetTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Facets::FacetTest < Minitest::Test
4
4
  def test_nested
5
5
  facet = Class.new(Arelastic::Facets::Facet) do
6
6
  def as_elastic_facet
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Facets::HistogramTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Facets::HistogramTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  facet = Arelastic::Facets::Histogram.new('histo', "field" => "field_name", "interval" => 100)
6
6
  expected = {
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Facets::TermsTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Facets::TermsTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  facet = Arelastic::Facets::Terms.new('foo', 'tags', "size" => 10)
6
6
  expected = {
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::ExistsTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::ExistsTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {"exists" => { "field" => "color" }}
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::FilterTest < MiniTest::Unit::TestCase
3
+ class Arelastic::FilterTest < Minitest::Test
4
4
  def test_or
5
5
  filter = Arelastic::Filters::Filter.new
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::GeoDistanceTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::GeoDistanceTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {
6
6
  "geo_distance" => {
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::HasChildTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::HasChildTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {"has_child" => {"type" => "comment", "query" => {"query_string" => "lol"}}}
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::IdsTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::IdsTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {"ids" => {"values" => ["foo", "bar"]}}
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::MatchAllTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::MatchAllTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  match_all = Arelastic::Queries::MatchAll.new
6
6
  expected = {"match_all" => {}}
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::MissingTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::MissingTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {"missing" => { "field" => "color" }}
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::NestedTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::NestedTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {
6
6
  "nested" => {
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::NotTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::NotTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {"not" => { "foo" => "bar" }}
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::QueryTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::QueryTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {"query" => { "match" => {"message" => "this is a test"} }}
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Filters::ScriptTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Filters::ScriptTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {"script" => {"script" => "doc['color'].value.charAt(0) == 'r'"}}
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Mappings::BinaryTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Mappings::BinaryTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  type = Arelastic::Mappings::Binary.new('message', 'index' => 'analyzed')
6
6
  expected = {'message' => {'type' => 'binary', 'index' => 'analyzed'}}
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Mappings::MultiFieldTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Mappings::MultiFieldTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  type = Arelastic::Mappings::MultiField.new('message', 'message' => {'type' => 'string', 'index' => 'analyzed'}, 'untouched' => {'type' => 'string', 'index' => 'not_analyzed'})
6
6
  expected = {
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Mappings::StringTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Mappings::StringTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  type = Arelastic::Mappings::String.new('message', 'index' => 'analyzed')
6
6
  expected = {'message' => {'type' => 'string', 'index' => 'analyzed'}}
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Nodes::NodeTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Nodes::NodeTest < Minitest::Test
4
4
  def test_equality
5
5
  node = Class.new(Arelastic::Nodes::Node) do
6
6
  def initialize(value)
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Queries::BoolTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Queries::BoolTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  bool = Arelastic::Queries::Bool.new(
6
6
  'must' => {
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Queries::FilteredTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Queries::FilteredTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  filtered = Arelastic::Queries::Filtered.new(
6
6
  query: {"query_string" => "bar"},
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Queries::MatchAllTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Queries::MatchAllTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  match_all = Arelastic::Queries::MatchAll.new
6
6
  expected = {"match_all" => {}}
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Queries::MultiMatchTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Queries::MultiMatchTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  query = "bar"
6
6
  fields = ["field_1", "field_2"]
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Queries::QueryStringTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Queries::QueryStringTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  query_string = Arelastic::Queries::QueryString.new('foo')
6
6
  expected = {"query_string" => {"query" => "foo"}}
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Queries::QueryTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Queries::QueryTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class Arelastic::Queries::WildcardTest < MiniTest::Unit::TestCase
3
+ class Arelastic::Queries::WildcardTest < Minitest::Test
4
4
  def test_as_elastic
5
5
  expected = {"wildcard" => {"foo" => "bar*"}}
6
6
 
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.8.0
4
+ version: 0.8.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-02-06 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Build Elastic Search queries with objects
14
14
  email: developer@matthewhiggins.com
@@ -21,6 +21,7 @@ files:
21
21
  - lib/arelastic.rb
22
22
  - lib/arelastic/aggregations.rb
23
23
  - lib/arelastic/aggregations/aggregation.rb
24
+ - lib/arelastic/aggregations/date_histogram.rb
24
25
  - lib/arelastic/aggregations/filter.rb
25
26
  - lib/arelastic/aggregations/min.rb
26
27
  - lib/arelastic/aggregations/nested.rb
@@ -102,6 +103,8 @@ files:
102
103
  - lib/arelastic/sorts.rb
103
104
  - lib/arelastic/sorts/asc.rb
104
105
  - lib/arelastic/sorts/sort.rb
106
+ - test/arelastic/aggregations/aggregation_test.rb
107
+ - test/arelastic/aggregations/date_histogram_test.rb
105
108
  - test/arelastic/aggregations/filter_test.rb
106
109
  - test/arelastic/aggregations/nested_test.rb
107
110
  - test/arelastic/aggregations/terms_test.rb
@@ -166,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
169
  version: 1.8.11
167
170
  requirements: []
168
171
  rubyforge_project:
169
- rubygems_version: 2.2.2
172
+ rubygems_version: 2.4.5
170
173
  signing_key:
171
174
  specification_version: 4
172
175
  summary: Elastic Search query builder