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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/elasticsearch-dsl.gemspec +4 -4
- data/lib/elasticsearch/dsl/search.rb +14 -0
- data/lib/elasticsearch/dsl/search/aggregations/range.rb +2 -1
- data/lib/elasticsearch/dsl/search/filters/has_child.rb +1 -0
- data/lib/elasticsearch/dsl/search/filters/has_parent.rb +1 -0
- data/lib/elasticsearch/dsl/search/options.rb +0 -1
- data/lib/elasticsearch/dsl/search/queries/has_child.rb +1 -0
- data/lib/elasticsearch/dsl/search/queries/has_parent.rb +1 -0
- data/lib/elasticsearch/dsl/search/queries/match.rb +1 -0
- data/lib/elasticsearch/dsl/search/queries/match_phrase.rb +33 -0
- data/lib/elasticsearch/dsl/search/queries/match_phrase_prefix.rb +32 -0
- data/lib/elasticsearch/dsl/search/queries/simple_query_string.rb +4 -2
- data/lib/elasticsearch/dsl/version.rb +1 -1
- data/test/integration/search_aggregation_children_test.rb +8 -3
- data/test/integration/search_aggregation_geo_test.rb +1 -1
- data/test/integration/search_aggregation_nested_test.rb +14 -8
- data/test/integration/search_aggregations_test.rb +14 -6
- data/test/integration/search_filters_test.rb +31 -120
- data/test/integration/search_query_test.rb +9 -1
- data/test/integration/search_size_from_test.rb +5 -1
- data/test/integration/search_sort_test.rb +4 -4
- data/test/integration/search_suggest_test.rb +32 -11
- data/test/integration/search_test.rb +1 -1
- data/test/test_helper.rb +24 -5
- data/test/unit/aggregations/avg_test.rb +1 -1
- data/test/unit/aggregations/cardinality_test.rb +5 -5
- data/test/unit/aggregations/children_test.rb +1 -1
- data/test/unit/aggregations/date_histogram_test.rb +1 -1
- data/test/unit/aggregations/date_range_test.rb +1 -1
- data/test/unit/aggregations/extended_stats_test.rb +1 -1
- data/test/unit/aggregations/filter_test.rb +1 -1
- data/test/unit/aggregations/filters_test.rb +1 -1
- data/test/unit/aggregations/geo_bounds_test.rb +1 -1
- data/test/unit/aggregations/geo_distance_test.rb +1 -1
- data/test/unit/aggregations/geohash_grid_test.rb +1 -1
- data/test/unit/aggregations/global_test.rb +1 -1
- data/test/unit/aggregations/histogram_test.rb +1 -1
- data/test/unit/aggregations/ip_range_test.rb +1 -1
- data/test/unit/aggregations/max_test.rb +1 -1
- data/test/unit/aggregations/min_test.rb +1 -1
- data/test/unit/aggregations/missing_test.rb +1 -1
- data/test/unit/aggregations/nested_test.rb +1 -1
- data/test/unit/aggregations/percentile_ranks_test.rb +1 -1
- data/test/unit/aggregations/percentiles_test.rb +1 -1
- data/test/unit/aggregations/pipeline/avg_bucket_test.rb +1 -1
- data/test/unit/aggregations/pipeline/bucket_script_test.rb +1 -1
- data/test/unit/aggregations/pipeline/bucket_selector_test.rb +1 -1
- data/test/unit/aggregations/pipeline/cumulative_sum_test.rb +1 -1
- data/test/unit/aggregations/pipeline/derivative_test.rb +1 -1
- data/test/unit/aggregations/pipeline/extended_stats_bucket_test.rb +1 -1
- data/test/unit/aggregations/pipeline/max_bucket_test.rb +1 -1
- data/test/unit/aggregations/pipeline/min_bucket_test.rb +1 -1
- data/test/unit/aggregations/pipeline/moving_avg_test.rb +1 -1
- data/test/unit/aggregations/pipeline/percentiles_bucket_test.rb +1 -1
- data/test/unit/aggregations/pipeline/serial_diff_test.rb +1 -1
- data/test/unit/aggregations/pipeline/stats_bucket_test.rb +1 -1
- data/test/unit/aggregations/pipeline/sum_bucket_test.rb +1 -1
- data/test/unit/aggregations/range_test.rb +12 -1
- data/test/unit/aggregations/reverse_nested_test.rb +2 -2
- data/test/unit/aggregations/scripted_metric_test.rb +1 -1
- data/test/unit/aggregations/significant_terms_test.rb +1 -1
- data/test/unit/aggregations/stats_test.rb +1 -1
- data/test/unit/aggregations/sum_test.rb +1 -1
- data/test/unit/aggregations/terms_test.rb +1 -1
- data/test/unit/aggregations/top_hits_test.rb +1 -1
- data/test/unit/aggregations/value_count_test.rb +1 -1
- data/test/unit/dsl_test.rb +1 -1
- data/test/unit/filters/and_test.rb +1 -1
- data/test/unit/filters/bool_test.rb +1 -1
- data/test/unit/filters/exists_test.rb +1 -1
- data/test/unit/filters/geo_bounding_box_test.rb +1 -1
- data/test/unit/filters/geo_distance_range_test.rb +1 -1
- data/test/unit/filters/geo_distance_test.rb +1 -1
- data/test/unit/filters/geo_polygon_test.rb +1 -1
- data/test/unit/filters/geo_shape_test.rb +5 -5
- data/test/unit/filters/geohash_cell_test.rb +1 -1
- data/test/unit/filters/has_child_test.rb +4 -2
- data/test/unit/filters/has_parent_test.rb +4 -2
- data/test/unit/filters/ids_test.rb +1 -1
- data/test/unit/filters/indices_test.rb +1 -1
- data/test/unit/filters/limit_test.rb +1 -1
- data/test/unit/filters/match_all_test.rb +2 -2
- data/test/unit/filters/missing_test.rb +1 -1
- data/test/unit/filters/nested_test.rb +1 -1
- data/test/unit/filters/not_test.rb +1 -1
- data/test/unit/filters/or_test.rb +1 -1
- data/test/unit/filters/prefix_test.rb +1 -1
- data/test/unit/filters/query_test.rb +1 -1
- data/test/unit/filters/range_test.rb +1 -1
- data/test/unit/filters/regexp_test.rb +1 -1
- data/test/unit/filters/script_test.rb +1 -1
- data/test/unit/filters/term_test.rb +1 -1
- data/test/unit/filters/terms_test.rb +1 -1
- data/test/unit/filters/type_test.rb +5 -5
- data/test/unit/queries/bool_test.rb +3 -3
- data/test/unit/queries/boosting_test.rb +1 -1
- data/test/unit/queries/common_test.rb +1 -1
- data/test/unit/queries/constant_score_test.rb +1 -1
- data/test/unit/queries/dis_max_test.rb +1 -1
- data/test/unit/queries/exists_test.rb +1 -1
- data/test/unit/queries/filtered_test.rb +1 -1
- data/test/unit/queries/function_score_test.rb +1 -1
- data/test/unit/queries/fuzzy_like_this_field_test.rb +5 -5
- data/test/unit/queries/fuzzy_like_this_test.rb +1 -1
- data/test/unit/queries/fuzzy_test.rb +1 -1
- data/test/unit/queries/geo_shape_test.rb +1 -1
- data/test/unit/queries/has_child_test.rb +4 -2
- data/test/unit/queries/has_parent_test.rb +4 -2
- data/test/unit/queries/ids_test.rb +1 -1
- data/test/unit/queries/indices_test.rb +1 -1
- data/test/unit/queries/match_all_test.rb +1 -1
- data/test/unit/queries/match_phrase_prefix_test.rb +62 -0
- data/test/unit/queries/match_phrase_test.rb +63 -0
- data/test/unit/queries/match_test.rb +1 -1
- data/test/unit/queries/more_like_this_test.rb +1 -1
- data/test/unit/queries/multi_match_test.rb +1 -1
- data/test/unit/queries/nested_test.rb +1 -1
- data/test/unit/queries/prefix_test.rb +5 -5
- data/test/unit/queries/query_string_test.rb +1 -1
- data/test/unit/queries/range_test.rb +1 -1
- data/test/unit/queries/regexp_test.rb +1 -1
- data/test/unit/queries/simple_query_string_test.rb +6 -8
- data/test/unit/queries/span_first_test.rb +1 -1
- data/test/unit/queries/span_multi_test.rb +1 -1
- data/test/unit/queries/span_near_test.rb +1 -1
- data/test/unit/queries/span_not_test.rb +1 -1
- data/test/unit/queries/span_or_test.rb +1 -1
- data/test/unit/queries/span_term_test.rb +1 -1
- data/test/unit/queries/template_test.rb +1 -1
- data/test/unit/queries/term_test.rb +1 -1
- data/test/unit/queries/terms_test.rb +1 -1
- data/test/unit/queries/top_children_test.rb +1 -1
- data/test/unit/queries/wildcard_test.rb +1 -1
- data/test/unit/search_aggregation_test.rb +1 -1
- data/test/unit/search_base_aggregation_component_test.rb +1 -1
- data/test/unit/search_base_component_test.rb +1 -1
- data/test/unit/search_filter_test.rb +1 -1
- data/test/unit/search_highlight_test.rb +1 -1
- data/test/unit/search_options_test.rb +1 -1
- data/test/unit/search_query_test.rb +1 -1
- data/test/unit/search_size_from_test.rb +1 -1
- data/test/unit/search_sort_test.rb +1 -1
- data/test/unit/search_suggest_test.rb +1 -1
- data/test/unit/search_test.rb +3 -1
- data/test/unit/utils_test.rb +1 -1
- metadata +24 -32
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
module Elasticsearch
|
4
4
|
module Test
|
5
5
|
module Filters
|
6
|
-
class TypeTest < ::Test::
|
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::
|
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 ConstantScoreTest < ::Test::
|
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 FunctionScoreTest < ::Test::
|
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::
|
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::
|
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 HasChildTest < ::Test::
|
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::
|
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
|
@@ -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
|