arelastic 0.4.0 → 0.4.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:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4b92649e00022c9304af5cb21befd2de463e89a8
         | 
| 4 | 
            +
              data.tar.gz: 031cbb1524ebe4bcc765f119118220d2271bded7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 28267da7724a8a038663db3530deb129fb5f89b5fb99c9cf4825fe4c254ff8a13fbc5e795bfde9b3339233c138f29c96fddb4e925369e91025f499057f82e225
         | 
| 7 | 
            +
              data.tar.gz: 0109427f5f49fcb44f391d60d19d88bfd081faaa55eec5eac6439870c848ebbfd1951a938e88e29ddb1dffe7bc97e61461e9979c686fd16e5289b02f77832fdb
         | 
| @@ -18,8 +18,8 @@ module Arelastic | |
| 18 18 | 
             
                      query Arelastic::Queries::MatchAll.new
         | 
| 19 19 | 
             
                    end
         | 
| 20 20 |  | 
| 21 | 
            -
                    def multi_match  | 
| 22 | 
            -
                       | 
| 21 | 
            +
                    def multi_match(query, fields, options = {})
         | 
| 22 | 
            +
                      query Arelastic::Queries::MultiMatch.new query, fields, options
         | 
| 23 23 | 
             
                    end
         | 
| 24 24 |  | 
| 25 25 | 
             
                    private
         | 
| @@ -1,6 +1,21 @@ | |
| 1 1 | 
             
            module Arelastic
         | 
| 2 2 | 
             
              module Queries
         | 
| 3 | 
            -
                class MultiMatch
         | 
| 3 | 
            +
                class MultiMatch < Query
         | 
| 4 | 
            +
                  attr_accessor :query, :fields, :options
         | 
| 5 | 
            +
                  def initialize(query, fields, options = {})
         | 
| 6 | 
            +
                    @query = query
         | 
| 7 | 
            +
                    @fields = fields
         | 
| 8 | 
            +
                    @options = options
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def as_elastic
         | 
| 12 | 
            +
                    {
         | 
| 13 | 
            +
                      "multi_match" => {
         | 
| 14 | 
            +
                        "query"   => convert_to_elastic(query),
         | 
| 15 | 
            +
                        "fields"  => convert_to_elastic(fields)
         | 
| 16 | 
            +
                      }.merge(options)
         | 
| 17 | 
            +
                    }
         | 
| 18 | 
            +
                  end
         | 
| 4 19 | 
             
                end
         | 
| 5 20 | 
             
              end
         | 
| 6 21 | 
             
            end
         | 
| @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            require 'helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Arelastic::Queries::MultiMatchTest < MiniTest::Unit::TestCase
         | 
| 4 | 
            +
              def test_as_elastic
         | 
| 5 | 
            +
                query = "bar"
         | 
| 6 | 
            +
                fields = ["field_1", "field_2"]
         | 
| 7 | 
            +
                multi_match = Arelastic::Queries::MultiMatch.new(query, fields)
         | 
| 8 | 
            +
                expected = {
         | 
| 9 | 
            +
                  "multi_match" => {
         | 
| 10 | 
            +
                    "query" => "bar",
         | 
| 11 | 
            +
                    "fields" => ["field_1", "field_2"]
         | 
| 12 | 
            +
                  }
         | 
| 13 | 
            +
                }
         | 
| 14 | 
            +
                assert_equal expected, multi_match.as_elastic
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              def test_as_elastic_with_options
         | 
| 18 | 
            +
                query = "bar"
         | 
| 19 | 
            +
                fields = []
         | 
| 20 | 
            +
                options = {
         | 
| 21 | 
            +
                  "use_dis_max" => false,
         | 
| 22 | 
            +
                  "tie_breaker" => 0.5
         | 
| 23 | 
            +
                }
         | 
| 24 | 
            +
                multi_match = Arelastic::Queries::MultiMatch.new(query, fields, options)
         | 
| 25 | 
            +
                expected = {
         | 
| 26 | 
            +
                  "multi_match" => {
         | 
| 27 | 
            +
                    "query" => "bar",
         | 
| 28 | 
            +
                    "fields" => [],
         | 
| 29 | 
            +
                    "use_dis_max" => false,
         | 
| 30 | 
            +
                    "tie_breaker" => 0.5
         | 
| 31 | 
            +
                  }
         | 
| 32 | 
            +
                }
         | 
| 33 | 
            +
                assert_equal expected, multi_match.as_elastic
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            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. | 
| 4 | 
            +
              version: 0.4.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: 2013- | 
| 11 | 
            +
            date: 2013-08-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: Build Elastic Search queries with objects
         | 
| 14 14 | 
             
            email: developer@matthewhiggins.com
         | 
| @@ -112,6 +112,7 @@ files: | |
| 112 112 | 
             
            - test/arelastic/nodes/node_test.rb
         | 
| 113 113 | 
             
            - test/arelastic/queries/filtered_test.rb
         | 
| 114 114 | 
             
            - test/arelastic/queries/match_all_test.rb
         | 
| 115 | 
            +
            - test/arelastic/queries/multi_match_test.rb
         | 
| 115 116 | 
             
            - test/arelastic/queries/query_string_test.rb
         | 
| 116 117 | 
             
            - test/arelastic/queries/query_test.rb
         | 
| 117 118 | 
             
            - test/arelastic/searches/sort_test.rb
         |