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 +4 -4
- data/lib/arelastic/filters/nested.rb +1 -11
- data/lib/arelastic/nodes.rb +2 -0
- data/lib/arelastic/nodes/nested.rb +22 -0
- data/lib/arelastic/queries.rb +1 -0
- data/lib/arelastic/queries/nested.rb +7 -0
- data/lib/arelastic/queries/query.rb +3 -0
- data/test/arelastic/queries/query_test.rb +13 -1
- metadata +4 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 87aa4611a9b69484f792da345e91c2fa81c0f3be
         | 
| 4 | 
            +
              data.tar.gz: 8163a78df33b8ec32a31afef6c39c676bd4e2432
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 | 
            -
                   | 
| 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
         | 
    
        data/lib/arelastic/nodes.rb
    CHANGED
    
    
| @@ -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
         | 
    
        data/lib/arelastic/queries.rb
    CHANGED
    
    | @@ -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'
         | 
| @@ -1,6 +1,18 @@ | |
| 1 1 | 
             
            require 'helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            class Arelastic::Queries::QueryTest < Minitest::Test
         | 
| 4 | 
            -
              def  | 
| 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. | 
| 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- | 
| 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
         |