arelastic 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6588673c2b9e8d9df21c34aab860bbcc16de2e13
4
- data.tar.gz: 0e4fb03df868f58c64d9037b33243d50bc89f476
3
+ metadata.gz: 4b92649e00022c9304af5cb21befd2de463e89a8
4
+ data.tar.gz: 031cbb1524ebe4bcc765f119118220d2271bded7
5
5
  SHA512:
6
- metadata.gz: 671121b401ed0f81e9a1b0f3826ebba614eb65818df1224c0886ab1f4a4a7acb09d3dc936a8796164ad170d349d1a7ba140eda973ff46b8d75ca49da4f32400e
7
- data.tar.gz: c0ffbce35123a1312ecb494fe666b0bdc2e9435433cdee40ada01029730f594b4d25a0d8bdc67aff8cb4e1b5df0389d9aff9402ec3832bc3f19b701581c0f2de
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 other, fields
22
- # Arelastic::Queries::MultiMatch.new other, fields
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.0
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-06-17 00:00:00.000000000 Z
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