elasticsearch-dsl 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/elasticsearch-dsl.gemspec +4 -4
  4. data/lib/elasticsearch/dsl/search.rb +14 -0
  5. data/lib/elasticsearch/dsl/search/aggregations/range.rb +2 -1
  6. data/lib/elasticsearch/dsl/search/filters/has_child.rb +1 -0
  7. data/lib/elasticsearch/dsl/search/filters/has_parent.rb +1 -0
  8. data/lib/elasticsearch/dsl/search/options.rb +0 -1
  9. data/lib/elasticsearch/dsl/search/queries/has_child.rb +1 -0
  10. data/lib/elasticsearch/dsl/search/queries/has_parent.rb +1 -0
  11. data/lib/elasticsearch/dsl/search/queries/match.rb +1 -0
  12. data/lib/elasticsearch/dsl/search/queries/match_phrase.rb +33 -0
  13. data/lib/elasticsearch/dsl/search/queries/match_phrase_prefix.rb +32 -0
  14. data/lib/elasticsearch/dsl/search/queries/simple_query_string.rb +4 -2
  15. data/lib/elasticsearch/dsl/version.rb +1 -1
  16. data/test/integration/search_aggregation_children_test.rb +8 -3
  17. data/test/integration/search_aggregation_geo_test.rb +1 -1
  18. data/test/integration/search_aggregation_nested_test.rb +14 -8
  19. data/test/integration/search_aggregations_test.rb +14 -6
  20. data/test/integration/search_filters_test.rb +31 -120
  21. data/test/integration/search_query_test.rb +9 -1
  22. data/test/integration/search_size_from_test.rb +5 -1
  23. data/test/integration/search_sort_test.rb +4 -4
  24. data/test/integration/search_suggest_test.rb +32 -11
  25. data/test/integration/search_test.rb +1 -1
  26. data/test/test_helper.rb +24 -5
  27. data/test/unit/aggregations/avg_test.rb +1 -1
  28. data/test/unit/aggregations/cardinality_test.rb +5 -5
  29. data/test/unit/aggregations/children_test.rb +1 -1
  30. data/test/unit/aggregations/date_histogram_test.rb +1 -1
  31. data/test/unit/aggregations/date_range_test.rb +1 -1
  32. data/test/unit/aggregations/extended_stats_test.rb +1 -1
  33. data/test/unit/aggregations/filter_test.rb +1 -1
  34. data/test/unit/aggregations/filters_test.rb +1 -1
  35. data/test/unit/aggregations/geo_bounds_test.rb +1 -1
  36. data/test/unit/aggregations/geo_distance_test.rb +1 -1
  37. data/test/unit/aggregations/geohash_grid_test.rb +1 -1
  38. data/test/unit/aggregations/global_test.rb +1 -1
  39. data/test/unit/aggregations/histogram_test.rb +1 -1
  40. data/test/unit/aggregations/ip_range_test.rb +1 -1
  41. data/test/unit/aggregations/max_test.rb +1 -1
  42. data/test/unit/aggregations/min_test.rb +1 -1
  43. data/test/unit/aggregations/missing_test.rb +1 -1
  44. data/test/unit/aggregations/nested_test.rb +1 -1
  45. data/test/unit/aggregations/percentile_ranks_test.rb +1 -1
  46. data/test/unit/aggregations/percentiles_test.rb +1 -1
  47. data/test/unit/aggregations/pipeline/avg_bucket_test.rb +1 -1
  48. data/test/unit/aggregations/pipeline/bucket_script_test.rb +1 -1
  49. data/test/unit/aggregations/pipeline/bucket_selector_test.rb +1 -1
  50. data/test/unit/aggregations/pipeline/cumulative_sum_test.rb +1 -1
  51. data/test/unit/aggregations/pipeline/derivative_test.rb +1 -1
  52. data/test/unit/aggregations/pipeline/extended_stats_bucket_test.rb +1 -1
  53. data/test/unit/aggregations/pipeline/max_bucket_test.rb +1 -1
  54. data/test/unit/aggregations/pipeline/min_bucket_test.rb +1 -1
  55. data/test/unit/aggregations/pipeline/moving_avg_test.rb +1 -1
  56. data/test/unit/aggregations/pipeline/percentiles_bucket_test.rb +1 -1
  57. data/test/unit/aggregations/pipeline/serial_diff_test.rb +1 -1
  58. data/test/unit/aggregations/pipeline/stats_bucket_test.rb +1 -1
  59. data/test/unit/aggregations/pipeline/sum_bucket_test.rb +1 -1
  60. data/test/unit/aggregations/range_test.rb +12 -1
  61. data/test/unit/aggregations/reverse_nested_test.rb +2 -2
  62. data/test/unit/aggregations/scripted_metric_test.rb +1 -1
  63. data/test/unit/aggregations/significant_terms_test.rb +1 -1
  64. data/test/unit/aggregations/stats_test.rb +1 -1
  65. data/test/unit/aggregations/sum_test.rb +1 -1
  66. data/test/unit/aggregations/terms_test.rb +1 -1
  67. data/test/unit/aggregations/top_hits_test.rb +1 -1
  68. data/test/unit/aggregations/value_count_test.rb +1 -1
  69. data/test/unit/dsl_test.rb +1 -1
  70. data/test/unit/filters/and_test.rb +1 -1
  71. data/test/unit/filters/bool_test.rb +1 -1
  72. data/test/unit/filters/exists_test.rb +1 -1
  73. data/test/unit/filters/geo_bounding_box_test.rb +1 -1
  74. data/test/unit/filters/geo_distance_range_test.rb +1 -1
  75. data/test/unit/filters/geo_distance_test.rb +1 -1
  76. data/test/unit/filters/geo_polygon_test.rb +1 -1
  77. data/test/unit/filters/geo_shape_test.rb +5 -5
  78. data/test/unit/filters/geohash_cell_test.rb +1 -1
  79. data/test/unit/filters/has_child_test.rb +4 -2
  80. data/test/unit/filters/has_parent_test.rb +4 -2
  81. data/test/unit/filters/ids_test.rb +1 -1
  82. data/test/unit/filters/indices_test.rb +1 -1
  83. data/test/unit/filters/limit_test.rb +1 -1
  84. data/test/unit/filters/match_all_test.rb +2 -2
  85. data/test/unit/filters/missing_test.rb +1 -1
  86. data/test/unit/filters/nested_test.rb +1 -1
  87. data/test/unit/filters/not_test.rb +1 -1
  88. data/test/unit/filters/or_test.rb +1 -1
  89. data/test/unit/filters/prefix_test.rb +1 -1
  90. data/test/unit/filters/query_test.rb +1 -1
  91. data/test/unit/filters/range_test.rb +1 -1
  92. data/test/unit/filters/regexp_test.rb +1 -1
  93. data/test/unit/filters/script_test.rb +1 -1
  94. data/test/unit/filters/term_test.rb +1 -1
  95. data/test/unit/filters/terms_test.rb +1 -1
  96. data/test/unit/filters/type_test.rb +5 -5
  97. data/test/unit/queries/bool_test.rb +3 -3
  98. data/test/unit/queries/boosting_test.rb +1 -1
  99. data/test/unit/queries/common_test.rb +1 -1
  100. data/test/unit/queries/constant_score_test.rb +1 -1
  101. data/test/unit/queries/dis_max_test.rb +1 -1
  102. data/test/unit/queries/exists_test.rb +1 -1
  103. data/test/unit/queries/filtered_test.rb +1 -1
  104. data/test/unit/queries/function_score_test.rb +1 -1
  105. data/test/unit/queries/fuzzy_like_this_field_test.rb +5 -5
  106. data/test/unit/queries/fuzzy_like_this_test.rb +1 -1
  107. data/test/unit/queries/fuzzy_test.rb +1 -1
  108. data/test/unit/queries/geo_shape_test.rb +1 -1
  109. data/test/unit/queries/has_child_test.rb +4 -2
  110. data/test/unit/queries/has_parent_test.rb +4 -2
  111. data/test/unit/queries/ids_test.rb +1 -1
  112. data/test/unit/queries/indices_test.rb +1 -1
  113. data/test/unit/queries/match_all_test.rb +1 -1
  114. data/test/unit/queries/match_phrase_prefix_test.rb +62 -0
  115. data/test/unit/queries/match_phrase_test.rb +63 -0
  116. data/test/unit/queries/match_test.rb +1 -1
  117. data/test/unit/queries/more_like_this_test.rb +1 -1
  118. data/test/unit/queries/multi_match_test.rb +1 -1
  119. data/test/unit/queries/nested_test.rb +1 -1
  120. data/test/unit/queries/prefix_test.rb +5 -5
  121. data/test/unit/queries/query_string_test.rb +1 -1
  122. data/test/unit/queries/range_test.rb +1 -1
  123. data/test/unit/queries/regexp_test.rb +1 -1
  124. data/test/unit/queries/simple_query_string_test.rb +6 -8
  125. data/test/unit/queries/span_first_test.rb +1 -1
  126. data/test/unit/queries/span_multi_test.rb +1 -1
  127. data/test/unit/queries/span_near_test.rb +1 -1
  128. data/test/unit/queries/span_not_test.rb +1 -1
  129. data/test/unit/queries/span_or_test.rb +1 -1
  130. data/test/unit/queries/span_term_test.rb +1 -1
  131. data/test/unit/queries/template_test.rb +1 -1
  132. data/test/unit/queries/term_test.rb +1 -1
  133. data/test/unit/queries/terms_test.rb +1 -1
  134. data/test/unit/queries/top_children_test.rb +1 -1
  135. data/test/unit/queries/wildcard_test.rb +1 -1
  136. data/test/unit/search_aggregation_test.rb +1 -1
  137. data/test/unit/search_base_aggregation_component_test.rb +1 -1
  138. data/test/unit/search_base_component_test.rb +1 -1
  139. data/test/unit/search_filter_test.rb +1 -1
  140. data/test/unit/search_highlight_test.rb +1 -1
  141. data/test/unit/search_options_test.rb +1 -1
  142. data/test/unit/search_query_test.rb +1 -1
  143. data/test/unit/search_size_from_test.rb +1 -1
  144. data/test/unit/search_sort_test.rb +1 -1
  145. data/test/unit/search_suggest_test.rb +1 -1
  146. data/test/unit/search_test.rb +3 -1
  147. data/test/unit/utils_test.rb +1 -1
  148. metadata +24 -32
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class MissingTest < ::Test::Unit::TestCase
6
+ class MissingTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Missing filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class NestedTest < ::Test::Unit::TestCase
6
+ class NestedTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Nested filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class NotTest < ::Test::Unit::TestCase
6
+ class NotTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Not filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class OrTest < ::Test::Unit::TestCase
6
+ class OrTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Or filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class PrefixTest < ::Test::Unit::TestCase
6
+ class PrefixTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Prefix filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class QueryTest < ::Test::Unit::TestCase
6
+ class QueryTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Query filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class RangeTest < ::Test::Unit::TestCase
6
+ class RangeTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Range filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class RegexpTest < ::Test::Unit::TestCase
6
+ class RegexpTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Regexp filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class ScriptTest < ::Test::Unit::TestCase
6
+ class ScriptTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Script filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class TermTest < ::Test::Unit::TestCase
6
+ class TermTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  subject { Term.new message: 'test' }
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class TermsTest < ::Test::Unit::TestCase
6
+ class TermsTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Terms filter" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Filters
6
- class TypeTest < ::Test::Unit::TestCase
6
+ class TypeTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Filters
8
8
 
9
9
  context "Type filter" do
@@ -12,17 +12,17 @@ module Elasticsearch
12
12
  should "be converted to a Hash" do
13
13
  assert_equal({ type: {} }, subject.to_hash)
14
14
  end
15
-
15
+
16
16
  should "have option methods" do
17
17
  subject = Type.new :foo
18
-
18
+
19
19
  subject.value 'bar'
20
-
20
+
21
21
  assert_equal %w[ value ],
22
22
  subject.to_hash[:type][:foo].keys.map(&:to_s).sort
23
23
  assert_equal 'bar', subject.to_hash[:type][:foo][:value]
24
24
  end
25
-
25
+
26
26
  should "take a block" do
27
27
  subject = Type.new :foo do
28
28
  value 'bar'
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class BoolTest < ::Test::Unit::TestCase
6
+ class BoolTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "Bool Query" do
@@ -37,13 +37,13 @@ module Elasticsearch
37
37
  end
38
38
 
39
39
  assert_equal( { bool:
40
- {
40
+ {
41
41
  minimum_should_match: 1,
42
42
  boost: 1.0,
43
43
  should: [ {term: { tag: 'wow' }}, {term: { tag: 'elasticsearch' }} ]
44
44
  }
45
45
  },
46
- subject.to_hash )
46
+ subject.to_hash )
47
47
  end
48
48
 
49
49
  should "take a block with multiple methods" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class BoostingTest < ::Test::Unit::TestCase
6
+ class BoostingTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "Boosting query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class CommonTest < ::Test::Unit::TestCase
6
+ class CommonTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "Common query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class ConstantScoreTest < ::Test::Unit::TestCase
6
+ class ConstantScoreTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "ConstantScore query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class DisMaxTest < ::Test::Unit::TestCase
6
+ class DisMaxTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "DisMax query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class ExistsTest < ::Test::Unit::TestCase
6
+ class ExistsTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "Exists query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class FilteredTest < ::Test::Unit::TestCase
6
+ class FilteredTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "Filtered query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class FunctionScoreTest < ::Test::Unit::TestCase
6
+ class FunctionScoreTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "FunctionScore query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class FuzzyLikeThisFieldTest < ::Test::Unit::TestCase
6
+ class FuzzyLikeThisFieldTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "FuzzyLikeThisField query" do
@@ -12,10 +12,10 @@ module Elasticsearch
12
12
  should "be converted to a Hash" do
13
13
  assert_equal({ fuzzy_like_this_field: {} }, subject.to_hash)
14
14
  end
15
-
15
+
16
16
  should "have option methods" do
17
17
  subject = FuzzyLikeThisField.new :foo
18
-
18
+
19
19
  subject.like_text 'bar'
20
20
  subject.fuzziness 'bar'
21
21
  subject.analyzer 'bar'
@@ -23,12 +23,12 @@ module Elasticsearch
23
23
  subject.prefix_length 'bar'
24
24
  subject.boost 'bar'
25
25
  subject.ignore_tf 'bar'
26
-
26
+
27
27
  assert_equal %w[ analyzer boost fuzziness ignore_tf like_text max_query_terms prefix_length ],
28
28
  subject.to_hash[:fuzzy_like_this_field][:foo].keys.map(&:to_s).sort
29
29
  assert_equal 'bar', subject.to_hash[:fuzzy_like_this_field][:foo][:like_text]
30
30
  end
31
-
31
+
32
32
  should "take a block" do
33
33
  subject = FuzzyLikeThisField.new :foo do
34
34
  like_text 'bar'
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class FuzzyLikeThisTest < ::Test::Unit::TestCase
6
+ class FuzzyLikeThisTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "FuzzyLikeThis query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class FuzzyTest < ::Test::Unit::TestCase
6
+ class FuzzyTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "Fuzzy query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class GeoShapeTest < ::Test::Unit::TestCase
6
+ class GeoShapeTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "GeoShape query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class HasChildTest < ::Test::Unit::TestCase
6
+ class HasChildTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "HasChild query" do
@@ -21,10 +21,12 @@ module Elasticsearch
21
21
  subject.score_mode 'bar'
22
22
  subject.min_children 'bar'
23
23
  subject.max_children 'bar'
24
+ subject.inner_hits({ size: 1 })
24
25
 
25
- assert_equal %w[ max_children min_children query score_mode type ],
26
+ assert_equal %w[ inner_hits max_children min_children query score_mode type ],
26
27
  subject.to_hash[:has_child].keys.map(&:to_s).sort
27
28
  assert_equal 'bar', subject.to_hash[:has_child][:type]
29
+ assert_equal({ size: 1 }, subject.to_hash[:has_child][:inner_hits])
28
30
  end
29
31
 
30
32
  should "take a block" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class HasParentTest < ::Test::Unit::TestCase
6
+ class HasParentTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "HasParent query" do
@@ -19,10 +19,12 @@ module Elasticsearch
19
19
  subject.parent_type 'bar'
20
20
  subject.query 'bar'
21
21
  subject.score_mode 'bar'
22
+ subject.inner_hits({ size: 1 })
22
23
 
23
- assert_equal %w[ parent_type query score_mode ],
24
+ assert_equal %w[ inner_hits parent_type query score_mode ],
24
25
  subject.to_hash[:has_parent].keys.map(&:to_s).sort
25
26
  assert_equal 'bar', subject.to_hash[:has_parent][:parent_type]
27
+ assert_equal({ size: 1 }, subject.to_hash[:has_parent][:inner_hits])
26
28
  end
27
29
 
28
30
  should "take a block" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class IdsTest < ::Test::Unit::TestCase
6
+ class IdsTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "Ids query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class IndicesTest < ::Test::Unit::TestCase
6
+ class IndicesTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "Indices query" do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Elasticsearch
4
4
  module Test
5
5
  module Queries
6
- class MatchAllTest < ::Test::Unit::TestCase
6
+ class MatchAllTest < ::Elasticsearch::Test::UnitTestCase
7
7
  include Elasticsearch::DSL::Search::Queries
8
8
 
9
9
  context "MatchAll query" do
@@ -0,0 +1,62 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ module Queries
6
+ class MatchPhrasePrefixTest < ::Elasticsearch::Test::UnitTestCase
7
+ include Elasticsearch::DSL::Search::Queries
8
+
9
+ context "Match Phrase Prefix Query" do
10
+ subject { MatchPhrasePrefix.new }
11
+
12
+ should "be converted to a Hash" do
13
+ assert_equal({ match_phrase_prefix: {} }, subject.to_hash)
14
+ end
15
+
16
+ should "take a concrete value" do
17
+ subject = MatchPhrasePrefix.new message: 'test'
18
+
19
+ assert_equal({match_phrase_prefix: {message: "test"}}, subject.to_hash)
20
+ end
21
+
22
+ should "have option methods" do
23
+ subject = MatchPhrasePrefix.new
24
+
25
+ subject.query 'bar'
26
+ subject.boost 10
27
+ subject.max_expansions 1
28
+
29
+ assert_equal %w[ boost max_expansions query ],
30
+ subject.to_hash[:match_phrase_prefix].keys.map(&:to_s).sort
31
+ assert_equal 'bar', subject.to_hash[:match_phrase_prefix][:query]
32
+ end
33
+
34
+ should "take a Hash" do
35
+ subject = MatchPhrasePrefix.new message: { query: 'test' }
36
+
37
+ assert_equal({match_phrase_prefix: {message: {query: "test" }}}, subject.to_hash)
38
+ end
39
+
40
+ should "take a block" do
41
+ subject = MatchPhrasePrefix.new :message do
42
+ query 'test'
43
+ boost 2
44
+ max_expansions 1
45
+ end
46
+
47
+ assert_equal({match_phrase_prefix: {message: {query: "test", max_expansions: 1, boost: 2 }}},
48
+ subject.to_hash)
49
+ end
50
+
51
+ should "take a method call" do
52
+ subject = MatchPhrasePrefix.new :message
53
+ subject.query 'test'
54
+
55
+ assert_equal({match_phrase_prefix: {message: {query: "test" }}}, subject.to_hash)
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,63 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ module Queries
6
+ class MatchPhraseTest < ::Elasticsearch::Test::UnitTestCase
7
+ include Elasticsearch::DSL::Search::Queries
8
+
9
+ context "Match Phrase Query" do
10
+ subject { MatchPhrase.new }
11
+
12
+ should "be converted to a Hash" do
13
+ assert_equal({ match_phrase: {} }, subject.to_hash)
14
+ end
15
+
16
+ should "take a concrete value" do
17
+ subject = MatchPhrase.new message: 'test'
18
+
19
+ assert_equal({match_phrase: {message: "test"}}, subject.to_hash)
20
+ end
21
+
22
+ should "have option methods" do
23
+ subject = MatchPhrase.new
24
+
25
+ subject.query 'bar'
26
+ subject.analyzer 'standard'
27
+ subject.boost 10
28
+ subject.slop 1
29
+
30
+ assert_equal %w[ analyzer boost query slop ],
31
+ subject.to_hash[:match_phrase].keys.map(&:to_s).sort
32
+ assert_equal 'bar', subject.to_hash[:match_phrase][:query]
33
+ end
34
+
35
+ should "take a Hash" do
36
+ subject = MatchPhrase.new message: { query: 'test' }
37
+
38
+ assert_equal({match_phrase: {message: {query: "test" }}}, subject.to_hash)
39
+ end
40
+
41
+ should "take a block" do
42
+ subject = MatchPhrase.new :message do
43
+ query 'test'
44
+ slop 1
45
+ boost 2
46
+ end
47
+
48
+ assert_equal({match_phrase: {message: {query: "test", slop: 1, boost: 2 }}},
49
+ subject.to_hash)
50
+ end
51
+
52
+ should "take a method call" do
53
+ subject = MatchPhrase.new :message
54
+ subject.query 'test'
55
+
56
+ assert_equal({match_phrase: {message: {query: "test" }}}, subject.to_hash)
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end