elasticated 2.5.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -2
  3. data/Rakefile +52 -1
  4. data/elasticated.gemspec +3 -1
  5. data/lib/elasticated.rb +20 -24
  6. data/lib/elasticated/aggregation.rb +3 -6
  7. data/lib/elasticated/aggregations/date_histogram_aggregation.rb +6 -1
  8. data/lib/elasticated/aggregations/filter_aggregation.rb +8 -12
  9. data/lib/elasticated/aggregations/filter_aggregation_evaluator.rb +1 -1
  10. data/lib/elasticated/aggregations/group_aggregation.rb +14 -11
  11. data/lib/elasticated/aggregations/range_aggregation.rb +10 -11
  12. data/lib/elasticated/aggregations/range_aggregation_evaluator.rb +1 -1
  13. data/lib/elasticated/aggregations/ranges_builder.rb +2 -2
  14. data/lib/elasticated/aggregations/safe_date_histogram_aggregation.rb +7 -2
  15. data/lib/elasticated/aggregations/subaggregated.rb +1 -1
  16. data/lib/elasticated/boolean_clause.rb +4 -3
  17. data/lib/elasticated/bulk_actions/create_action.rb +14 -0
  18. data/lib/elasticated/bulk_actions/delete_action.rb +30 -0
  19. data/lib/elasticated/bulk_actions/index_action.rb +35 -0
  20. data/lib/elasticated/bulk_actions/standard_action.rb +22 -0
  21. data/lib/elasticated/bulk_actions/update_action.rb +44 -0
  22. data/lib/elasticated/bulk_actions/upsert_action.rb +14 -0
  23. data/lib/elasticated/bulk_request.rb +58 -0
  24. data/lib/elasticated/bulk_request/response.rb +32 -0
  25. data/lib/elasticated/bulk_request/response_item.rb +39 -0
  26. data/lib/elasticated/client.rb +27 -3
  27. data/lib/elasticated/conditions/custom_condition.rb +3 -3
  28. data/lib/elasticated/conditions/range_condition.rb +5 -2
  29. data/lib/elasticated/conditions/script_condition.rb +3 -3
  30. data/lib/elasticated/conditions/standard_condition.rb +4 -5
  31. data/lib/elasticated/conditions/term_condition.rb +22 -0
  32. data/lib/elasticated/conditions/terms_condition.rb +2 -2
  33. data/lib/elasticated/conditions_builder.rb +19 -4
  34. data/lib/elasticated/delimiters/date_field_delimiter.rb +21 -12
  35. data/lib/elasticated/delimiters/standard_field_delimiter.rb +18 -2
  36. data/lib/elasticated/delimiters/term_field_delimiter.rb +6 -5
  37. data/lib/elasticated/document.rb +20 -1
  38. data/lib/elasticated/enum.rb +17 -0
  39. data/lib/elasticated/index_selector.rb +26 -25
  40. data/lib/elasticated/mapping.rb +2 -4
  41. data/lib/elasticated/mapping/builder.rb +3 -2
  42. data/lib/elasticated/mapping/fields_builder.rb +13 -9
  43. data/lib/elasticated/mapping/object_builder.rb +38 -4
  44. data/lib/elasticated/mapping/type_builder.rb +3 -5
  45. data/lib/elasticated/mixins/block_evaluation.rb +17 -0
  46. data/lib/elasticated/mixins/clonable.rb +60 -0
  47. data/lib/elasticated/mixins/configurable.rb +22 -0
  48. data/lib/elasticated/mixins/inspectionable.rb +16 -0
  49. data/lib/elasticated/partitioned_repository.rb +24 -18
  50. data/lib/elasticated/query.rb +27 -21
  51. data/lib/elasticated/query_aggregations.rb +5 -7
  52. data/lib/elasticated/query_conditions.rb +6 -3
  53. data/lib/elasticated/quick.rb +7 -0
  54. data/lib/elasticated/repository.rb +184 -40
  55. data/lib/elasticated/repository/intelligent_search.rb +3 -3
  56. data/lib/elasticated/repository/normal_search.rb +2 -2
  57. data/lib/elasticated/repository/resumable_search.rb +5 -5
  58. data/lib/elasticated/repository/scan_scroll_search.rb +4 -4
  59. data/lib/elasticated/repository/scroll_search.rb +3 -3
  60. data/lib/elasticated/repository/search.rb +7 -0
  61. data/lib/elasticated/repository/single_page_search.rb +1 -1
  62. data/lib/elasticated/results.rb +14 -0
  63. data/lib/version.rb +18 -25
  64. data/spec/aggregation_spec.rb +95 -16
  65. data/spec/bulk_request_spec.rb +158 -0
  66. data/spec/date_field_delimiter_spec.rb +50 -6
  67. data/spec/document_spec.rb +1 -5
  68. data/spec/integration_spec.rb +7 -7
  69. data/spec/mapping_spec.rb +128 -8
  70. data/spec/partitioned_repository_spec.rb +218 -0
  71. data/spec/query_conditions_spec.rb +98 -45
  72. data/spec/query_spec.rb +21 -28
  73. data/spec/repository_spec.rb +245 -0
  74. data/spec/results_spec.rb +0 -4
  75. data/spec/sample_responses/elasticsearch_bulk_response_1.json +35 -0
  76. data/spec/sample_responses/elasticsearch_bulk_response_2.json +20 -0
  77. data/spec/sample_responses/elasticsearch_count_1.json +8 -0
  78. data/spec/sample_responses/elasticsearch_count_2.json +8 -0
  79. data/spec/sample_responses/elasticsearch_get_response_1.json +10 -0
  80. data/spec/sample_responses/elasticsearch_get_response_2.json +6 -0
  81. data/spec/{elasticsearch_hit_1.json → sample_responses/elasticsearch_hit_1.json} +0 -0
  82. data/spec/sample_responses/elasticsearch_mget_response_1.json +25 -0
  83. data/spec/{elasticsearch_response_1.json → sample_responses/elasticsearch_response_1.json} +0 -0
  84. data/spec/{elasticsearch_response_2.json → sample_responses/elasticsearch_response_2.json} +0 -0
  85. data/spec/{elasticsearch_top_hits_response.json → sample_responses/elasticsearch_top_hits_response.json} +0 -0
  86. data/spec/spec_helper.rb +47 -0
  87. data/spec/spec_helper/fake_index_selector.rb +27 -0
  88. data/spec/term_field_delimiter_spec.rb +8 -8
  89. metadata +80 -26
  90. data/lib/elasticated/block_evaluation.rb +0 -15
  91. data/lib/elasticated/clonable.rb +0 -58
  92. data/lib/elasticated/configurable.rb +0 -20
  93. data/lib/elasticated/date_delimiter_factory.rb +0 -123
  94. data/lib/elasticated/delimiter_visitor.rb +0 -53
  95. data/lib/elasticated/inspectionable.rb +0 -9
  96. data/lib/elasticated/strategy_params_for_query_service.rb +0 -14
  97. data/lib/elasticated/term_delimiter_factory.rb +0 -73
  98. data/spec/delimiter_factory_spec.rb +0 -399
  99. data/spec/strategy_params_for_query_service_spec.rb +0 -387
@@ -1,15 +0,0 @@
1
- module Elasticated
2
- module BlockEvaluation
3
-
4
- def evaluate(block=nil, obj=nil)
5
- return unless block
6
- obj ||= self
7
- if block.parameters.empty?
8
- obj.instance_exec &block
9
- else
10
- block.call obj
11
- end
12
- end
13
-
14
- end
15
- end
@@ -1,58 +0,0 @@
1
- module Elasticated
2
- module Clonable
3
-
4
- def clone
5
- ret = super
6
- instance_variables.each do |instance_variable|
7
- value = instance_variable_get instance_variable
8
- value = case value.class
9
- when Array
10
- clone_array value
11
- when Hash
12
- Helpers.hash_deep_dup value
13
- else
14
- value.clone
15
- end
16
- ret.instance_variable_set instance_variable, value
17
- end
18
- ret
19
- end
20
-
21
- def ==(other_entity)
22
- other_entity.class == self.class &&
23
- instance_variables.all? do |instance_variable|
24
- next true if instance_variable == :@_subaggregations # Subaggregated
25
- value = instance_variable_get instance_variable
26
- other_value = other_entity.instance_variable_get instance_variable
27
- case other_value.class
28
- when Array
29
- compare_arrays value, other_value
30
- else
31
- other_value == value
32
- end
33
- end
34
- end
35
-
36
- private
37
-
38
- def clone_array(array)
39
- array.map do |element|
40
- case element.class
41
- when Hash
42
- Helpers.hash_deep_dup element
43
- when Array
44
- clone_array element
45
- else
46
- element.clone
47
- end
48
- end
49
- end
50
-
51
- def compare_arrays(array_a, array_b)
52
- array_a.all? do |element|
53
- array_b.include? element
54
- end && array_a.size == array_b.size
55
- end
56
-
57
- end
58
- end
@@ -1,20 +0,0 @@
1
- module Elasticated
2
- module Configurable
3
-
4
- def self.delegated(attr_name)
5
- define_method attr_name do
6
- instance_variable_get("@#{attr_name}") || Configuration.send(attr_name)
7
- end
8
- define_method "#{attr_name}=" do |value|
9
- instance_variable_set "@#{attr_name}", value
10
- end
11
- end
12
-
13
- delegated :logger
14
- alias_method :log, :logger
15
- delegated :scroll_expiration_time
16
- delegated :scroll_page_size
17
- delegated :search_page_size
18
-
19
- end
20
- end
@@ -1,123 +0,0 @@
1
- module Elasticated
2
- class DateDelimiterFactory
3
-
4
- def create(empty_delimiter, query_delimiters, opts={})
5
- klass = Delimiters::DateFieldDelimiter
6
- field = empty_delimiter.field_name
7
- filter_name = empty_delimiter.filter_name
8
- field_since = "#{field}_since".to_sym
9
- field_until = "#{field}_until".to_sym
10
- filter_since = "#{filter_name}_since".to_sym
11
- filter_until = "#{filter_name}_until".to_sym
12
- field_term = field.to_sym
13
- delimit_by = opts.fetch(:delimit_by, [:conditions])
14
-
15
- case delimit_by
16
- when []
17
- _since = nil
18
- _until = nil
19
- when [:conditions]
20
- if has_terms?(query_delimiters, :conditions, field_term)
21
- _since = since_condition_delimiters(query_delimiters.fetch(:conditions, []), field_term)
22
- _until = until_condition_delimiters(query_delimiters.fetch(:conditions, []), field_term)
23
- else
24
- _since = since_condition_delimiters(query_delimiters.fetch(:conditions, []), field_since)
25
- _until = until_condition_delimiters(query_delimiters.fetch(:conditions, []), field_until)
26
- end
27
- when [:aggregations]
28
- if has_terms?(query_delimiters, :aggregations, field_term)
29
- _since = since_aggregation_delimiters(query_delimiters.fetch(:aggregations, []), field_term)
30
- _until = until_aggregation_delimiters(query_delimiters.fetch(:aggregations, []), field_term)
31
- else
32
- _since = since_aggregation_delimiters(query_delimiters.fetch(:aggregations, []), field_since)
33
- _until = until_aggregation_delimiters(query_delimiters.fetch(:aggregations, []), field_until)
34
- end
35
- when [:conditions, :aggregations]
36
- if has_terms?(query_delimiters, :conditions, field_term)
37
- _since = since_condition_delimiters(query_delimiters.fetch(:conditions, []), field_term)
38
- _until = until_condition_delimiters(query_delimiters.fetch(:conditions, []), field_term)
39
- _since = since_aggregation_delimiters(query_delimiters.fetch(:aggregations, []), field_term) if _since.nil?
40
- _until = until_aggregation_delimiters(query_delimiters.fetch(:aggregations, []), field_term) if _until.nil?
41
- else
42
- condition_since = since_condition_delimiters(query_delimiters.fetch(:conditions, []), field_since)
43
- condition_until = until_condition_delimiters(query_delimiters.fetch(:conditions, []), field_until)
44
- aggregation_since = since_aggregation_delimiters(query_delimiters.fetch(:aggregations, []), field_since)
45
- aggregation_until = until_aggregation_delimiters(query_delimiters.fetch(:aggregations, []), field_until)
46
- _since = condition_since || aggregation_since
47
- _until = condition_until || aggregation_until
48
- end
49
- end
50
-
51
- filtered_empty_delimiter = {
52
- filter_since => _since,
53
- filter_until => _until
54
- }.select { |_, v| not v.nil? }
55
-
56
- klass.new(filtered_empty_delimiter.merge(field: field, as: filter_name))
57
- end
58
-
59
- private
60
-
61
- def since_aggregation_delimiters(all_aggregation_delimiters, field_since)
62
- return nil if missing_field?(all_aggregation_delimiters, field_since)
63
- return min_since_delimiter(all_aggregation_delimiters, field_since) if all_aggregation_delimiters.any? { |delimiter| delimiter[field_since].is_a? Array }
64
- since_delimiters = all_aggregation_delimiters.min_by { |delimiter| delimiter[field_since] }
65
- since_delimiters.nil? ? nil : since_delimiters[field_since]
66
- end
67
-
68
- def since_condition_delimiters(all_condition_delimiters, field_since)
69
- condition_delimiterts_with_field = all_condition_delimiters.select { |delimiter| delimiter[field_since] }
70
- return min_since_delimiter(condition_delimiterts_with_field, field_since) if condition_delimiterts_with_field.any? { |delimiter| delimiter[field_since].is_a? Array }
71
- since_delimiters = condition_delimiterts_with_field.min_by { |delimiter| delimiter[field_since] }
72
- since_delimiters.nil? ? nil : since_delimiters[field_since]
73
- end
74
-
75
- def min_since_delimiter(delimiters, field)
76
- array_delimiters = delimiters.select { |delimiter| delimiter[field].is_a? Array }
77
- min_array_delimiter = array_delimiters.min_by { |delimiter| delimiter[field].min }
78
- individual_delimiters = delimiters.select { |delimiter| not delimiter[field].is_a? Array }
79
- min_individual_delimiter = individual_delimiters.min_by { |delimiter| delimiter[field] }
80
- if not (min_array_delimiter.nil? or min_individual_delimiter.nil?)
81
- min_array_delimiter > min_individual_delimiter ? min_individual_delimiter : min_array_delimiter
82
- else
83
- return min_array_delimiter[field].min if min_array_delimiter and min_array_delimiter[field].min
84
- min_individual_delimiter
85
- end
86
- end
87
-
88
- def until_aggregation_delimiters(all_aggregation_delimiters, field_until)
89
- return nil if missing_field?(all_aggregation_delimiters, field_until)
90
- return max_until_delimiter(all_aggregation_delimiters, field_until) if all_aggregation_delimiters.any? { |delimiter| delimiter[field_until].is_a? Array }
91
- until_delimiters = all_aggregation_delimiters.max_by { |delimiter| delimiter[field_until] }
92
- until_delimiters.nil? ? nil : until_delimiters[field_until]
93
- end
94
-
95
- def until_condition_delimiters(all_condition_delimiters, field_until)
96
- condition_delimiterts_with_field = all_condition_delimiters.select { |delimiter| delimiter[field_until] }
97
- return max_until_delimiter(condition_delimiterts_with_field, field_until) if condition_delimiterts_with_field.any? { |delimiter| delimiter[field_until].is_a? Array }
98
- until_delimiters = condition_delimiterts_with_field.max_by { |delimiter| delimiter[field_until] }
99
- until_delimiters.nil? ? nil : until_delimiters[field_until]
100
- end
101
-
102
- def max_until_delimiter(delimiters, field)
103
- array_delimiters = delimiters.select { |delimiter| delimiter[field].is_a? Array }
104
- max_array_delimiter = array_delimiters.max_by { |delimiter| delimiter[field].max }
105
- individual_delimiters = delimiters.select { |delimiter| not delimiter[field].is_a? Array }
106
- max_individual_delimiter = individual_delimiters.max_by { |delimiter| delimiter[field] }
107
- if not (max_array_delimiter.nil? or max_individual_delimiter.nil?)
108
- max_array_delimiter > max_individual_delimiter ? max_individual_delimiter : max_array_delimiter
109
- else
110
- return max_array_delimiter[field].max if max_array_delimiter and max_array_delimiter[field].max
111
- max_individual_delimiter
112
- end
113
- end
114
-
115
- def missing_field?(delimiters, field)
116
- delimiters.any? { |delimiter| not delimiter.has_key?(field) }
117
- end
118
-
119
- def has_terms?(delimiters, condition_or_agg, field)
120
- delimiters.fetch(condition_or_agg, []).any? { |delimiter| delimiter[field] }
121
- end
122
- end
123
- end
@@ -1,53 +0,0 @@
1
- module Elasticated
2
- class DelimiterVisitor
3
-
4
- def visit_query(query)
5
- {
6
- conditions: query._conditions.accept_visitor(self) + query._filter_conditions.accept_visitor(self),
7
- aggregations: query._aggregations.accept_visitor(self)
8
- }
9
- end
10
-
11
- def visit_query_conditions(query_conditions)
12
- query_conditions._must.accept_visitor(self)
13
- end
14
-
15
- def visit_boolean_clause(boolean_clause)
16
- boolean_clause.conditions.flat_map { |c| c.accept_visitor(self) }
17
- end
18
-
19
- def visit_condition(condition)
20
- {}
21
- end
22
-
23
- def visit_terms(terms_condition)
24
- { terms_condition.field => terms_condition.values }
25
- end
26
-
27
- def visit_range(range_condition)
28
- field = range_condition.field
29
- minimum_value = range_condition.body[:gt] || range_condition.body[:gte]
30
- maximum_value = range_condition.body[:lt] || range_condition.body[:lte]
31
-
32
- {}.tap do |h|
33
- h["#{field}_since".to_sym] = minimum_value if minimum_value
34
- h["#{field}_until".to_sym] = maximum_value if maximum_value
35
- end
36
- end
37
-
38
- def visit_query_aggregations(query_aggregations)
39
- query_aggregations._aggregations.inject([]) do |acum, aggregation|
40
- acum + [aggregation.accept_visitor(self).inject(:merge)].compact
41
- end
42
- end
43
-
44
- def visit_aggregation(aggregation)
45
- []
46
- end
47
-
48
- def visit_filter_aggregation(filter_aggregation)
49
- filter_aggregation._subaggregations._conditions.accept_visitor(self).flatten(1)
50
- end
51
-
52
- end
53
- end
@@ -1,9 +0,0 @@
1
- module Elasticated
2
- module Inspectionable
3
-
4
- def inspect
5
- "#<#{self.class.name}:#{build}>"
6
- end
7
-
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- module Elasticated
2
- class StrategyParamsForQueryService
3
-
4
- def strategy_params_for_query(empty_delimiters, query, opts={})
5
- query_delimiters = query.accept_visitor(Elasticated.delimiter_visitor)
6
-
7
- empty_delimiters.inject Hash.new do |params, empty_delimiter|
8
- built_delimiter = empty_delimiter.completed_with(query_delimiters, opts)
9
- params.merge built_delimiter.build_strategy_params
10
- end
11
- end
12
-
13
- end
14
- end
@@ -1,73 +0,0 @@
1
- module Elasticated
2
- class TermDelimiterFactory
3
-
4
- def create(empty_delimiter, query_delimiters, opts={})
5
- klass = Delimiters::TermFieldDelimiter
6
- field = empty_delimiter.field_name
7
- delimit_by = opts.fetch(:delimit_by, [:conditions])
8
-
9
- case delimit_by
10
- when []
11
- relevant_delimiters = []
12
- when [:conditions]
13
- relevant_delimiters = relevant_field_delimiters(query_delimiters.fetch(:conditions), field)
14
- when [:aggregations]
15
- relevant_delimiters = relevant_field_delimiters(query_delimiters.fetch(:aggregations), field)
16
- else
17
- condition_delimiters = query_delimiters.fetch(:conditions)
18
- aggregation_delimiters = query_delimiters.fetch(:aggregations)
19
- relevant_delimiters = [merge_delimiters(condition_delimiters, aggregation_delimiters,field)]
20
- end
21
-
22
- values = empty_delimiter.values + relevant_delimiters.flat_map(&:values).flatten(1)
23
- klass.new(values: values, field: field, as: empty_delimiter.filter_name)
24
- end
25
-
26
-
27
- def relevant_field_delimiters(all_delimiters, field)
28
- all_delimiters.each_with_object(Array.new) do |delimiter, array|
29
- field_delimiter = delimiter.select { |k,_| k == field }
30
- array << field_delimiter unless field_delimiter.empty?
31
- end
32
- end
33
-
34
- def merge_delimiters(condition_delimiters, aggregation_delimiters, field)
35
- aggregation_delimiters_by_field = extract_aggregation_delimiters(aggregation_delimiters, field)
36
- condition_delimiters_by_field = extract_condition_delimiters(condition_delimiters,field)
37
- aggregation_delimiters_by_field.merge condition_delimiters_by_field
38
- end
39
-
40
- private
41
-
42
- def extract_aggregation_delimiters(delimiters, field)
43
- first_delimiter = delimiters.first || {}
44
- delimiters.inject(first_delimiter) do |mcd_acum, delimiter|
45
- merge_aggregation_repeated_keys(mcd_acum, delimiter, field)
46
- end
47
- end
48
-
49
- def extract_condition_delimiters(delimiters, field)
50
- first_delimiter = delimiters.first || {}
51
- delimiters.inject(first_delimiter) do |mcd_acum, delimiter|
52
- merge_condition_repeated_keys(mcd_acum, delimiter, field)
53
- end
54
- end
55
-
56
- def merge_aggregation_repeated_keys(this, another_hash, field)
57
- this_field = this[field]
58
- another_hash_field = another_hash[field]
59
- return {} if this_field.nil? or another_hash_field.nil?
60
- {field => (this_field + another_hash_field).uniq}
61
- end
62
-
63
- def merge_condition_repeated_keys(this, another_hash, field)
64
- this_field = this[field]
65
- another_hash_field = another_hash[field]
66
- return this if another_hash_field.nil? and not this_field.nil?
67
- return (another_hash.select { |(k,v)| k == field }) if this_field.nil? and not another_hash_field.nil?
68
- return {} if another_hash_field.nil? and this_field.nil?
69
- {field => (this_field + another_hash_field).uniq}
70
- end
71
-
72
- end
73
- end
@@ -1,399 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- module Elasticated
4
- describe TermDelimiterFactory do
5
- let(:empty_delimiter){ Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts) }
6
-
7
- it "should create empty term delimiter from empty conditions" do
8
- query_delimiters = { conditions: [], aggregations: []}
9
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [])
10
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
11
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
12
- end
13
-
14
- it 'should create empty term delimiter from empty condition delimiter definition and none aggregation delimiters' do
15
- query_delimiters = { conditions: [{}], aggregations: [] }
16
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [])
17
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
18
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
19
-
20
- query_delimiters = { conditions: [{}, {}], aggregations: [] }
21
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
22
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
23
- end
24
-
25
- it 'should create term delimiter with account from condition delimiter' do
26
- query_delimiters = { conditions: [{account: [39]}], aggregations: [] }
27
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39])
28
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
29
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
30
- end
31
-
32
- it 'should create term delimiter with account from condition delimiter with other empty definitions' do
33
- query_delimiters = { conditions: [{account: [39]}, {}, {}], aggregations: [] }
34
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39])
35
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
36
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
37
-
38
- query_delimiters = { conditions: [{account: [39,40]}, {}, {}], aggregations: [] }
39
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39,40])
40
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
41
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
42
- end
43
-
44
- it 'should create term delimiter with two accounts from different condition delimiters' do
45
- query_delimiters = { conditions: [{account: [39]}, {account: 40}, {}], aggregations: [] }
46
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39, 40])
47
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
48
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
49
- end
50
-
51
- it 'should create term delimiter with two accounts from different condition delimiters with one different field in one delimiter' do
52
- query_delimiters = { conditions: [{account: [39], tags: ["a_tag"]}, {account: 40}, {}], aggregations: [] }
53
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39, 40])
54
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
55
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
56
-
57
- query_delimiters = { conditions: [{account: [39], tags: ["a_tag"]}, {account: 40, tags: ["another_tag"]}, {}], aggregations: [] }
58
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters)
59
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
60
- end
61
-
62
- it 'should create term delimiter with account from aggregation delimiter with no condition delimiters' do
63
- options = {delimit_by: [:aggregations]}
64
- query_delimiters = { conditions: [{}], aggregations: [{account: [39]}] }
65
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39])
66
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
67
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
68
-
69
- query_delimiters = { conditions: [{}], aggregations: [{account: [39]}, {account: [40]}] }
70
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39, 40])
71
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
72
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
73
- end
74
-
75
- it 'should create term delimiter with two account from aggregation delimiter when delimiting by aggregations' do
76
- options = {delimit_by: [:aggregations]}
77
- query_delimiters = { conditions: [], aggregations: [{account: [39]}, {account: [40]}] }
78
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39,40])
79
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
80
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
81
- end
82
-
83
- it 'should create term delimiter with no accounts from aggregation delimiter when there are at least one condition delimiters' do
84
- options = {delimit_by: [:conditions, :aggregations]}
85
- query_delimiters = { conditions: [{account: [31]}], aggregations: [{account: [39]}, {account: [40]}] }
86
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [31])
87
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
88
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
89
- end
90
-
91
- it 'should create term delimiter with two accounts from aggregation delimiter when there are no condition delimiters' do
92
- options = {delimit_by: [:conditions, :aggregations]}
93
- query_delimiters = { conditions: [], aggregations: [{account: [39]}, {account: [40]}] }
94
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39,40])
95
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
96
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
97
- end
98
-
99
- it 'should create term delimiter with two accounts from condition delimiters when there are not aggregation delimiters' do
100
- options = {delimit_by: [:conditions, :aggregations]}
101
- query_delimiters = { conditions: [{account: [39]}, {account: [40]}], aggregations: [] }
102
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :account, as: :accounts, values: [39,40])
103
- actual = Elasticated.term_delimiter_factory.create(empty_delimiter, query_delimiters, options)
104
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
105
- end
106
-
107
- it 'should merge empty delimiters' do
108
- condition_delimiters = []
109
- aggregation_delimiters = []
110
- field = :account
111
- expected = {}
112
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
113
- expect(actual).to eq(expected)
114
- end
115
-
116
- it 'should merge empty condition delimiter with one aggregation delimiter' do
117
- condition_delimiters = []
118
- aggregation_delimiters = [{account: [39]}]
119
- field = :account
120
- expected = {account: [39]}
121
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
122
- expect(actual).to eq(expected)
123
- end
124
-
125
- it 'should merge empty condition delimiter with two aggregation delimiters' do
126
- condition_delimiters = []
127
- aggregation_delimiters = [{account: [39]}, {account: [40]}]
128
- field = :account
129
- expected = {account: [39, 40]}
130
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
131
- expect(actual).to eq(expected)
132
- end
133
-
134
- it 'should merge empty condition delimiter with two different aggregation delimiters' do
135
- condition_delimiters = []
136
- aggregation_delimiters = [{account: [39]}, {tags: ["a_tag"]}]
137
- field = :account
138
- expected = {}
139
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
140
- expect(actual).to eq(expected)
141
-
142
- aggregation_delimiters = [{tags: ["a_tag"]}, {account: [39]}]
143
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
144
- expect(actual).to eq(expected)
145
- end
146
-
147
- it 'should merge empty condition delimiter with two equal aggregation delimiters and one different' do
148
- condition_delimiters = [{}]
149
- aggregation_delimiters = [{account: [39]}, {account: [40], tags: ["a_tag"]}]
150
- field = :account
151
- expected = {account: [39, 40]}
152
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
153
- expect(actual).to eq(expected)
154
- end
155
-
156
- it 'should merge one condition delimiter with empty aggregation delimiters' do
157
- condition_delimiters = [{account: [39]}]
158
- aggregation_delimiters = [{}]
159
- field = :account
160
- expected = {account: [39]}
161
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
162
- expect(actual).to eq(expected)
163
- end
164
-
165
- it 'should merge two condition delimiter with empty aggregation delimiters' do
166
- condition_delimiters = [{account: [39]}, {account: [40]}]
167
- aggregation_delimiters = [{}]
168
- field = :account
169
- expected = {account: [39, 40]}
170
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
171
- expect(actual).to eq(expected)
172
- end
173
-
174
- it 'should merge two different condition delimiters with empty aggregation delimiters' do
175
- condition_delimiters = [{account: [39]}, {tags: ["a_tag"]}]
176
- aggregation_delimiters = [{}]
177
- field = :account
178
- expected = {account: [39]}
179
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
180
- expect(actual).to eq(expected)
181
-
182
- condition_delimiters = [{tags: ["a_tag"]}, {account: [39]}]
183
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
184
- expect(actual).to eq(expected)
185
- end
186
-
187
- it 'should merge two equal and one different condition delimiters with empty delimiters' do
188
- condition_delimiters = [{account: [39]}, {account: [40], tags: ["a_tag"]}]
189
- aggregation_delimiters = [{}]
190
- field = :account
191
- expected = {account: [39, 40]}
192
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
193
- expect(actual).to eq(expected)
194
-
195
- condition_delimiters = [{tags: ["a_tag"], account: [40]}, {account: [39]}]
196
- expected = {account: [40, 39]}
197
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
198
- expect(actual).to eq(expected)
199
- end
200
-
201
- it 'should merge one condition delimiter with one aggregation delimiter of a different field' do
202
- condition_delimiters = [{account: [39]}]
203
- aggregation_delimiters = [{tags: ["a_tag"]}]
204
- field = :account
205
- expected = {account: [39]}
206
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
207
- expect(actual).to eq(expected)
208
- end
209
-
210
- it 'should merge one condition delimiter with one aggregation delimiter of the same field' do
211
- condition_delimiters = [{account: [39]}]
212
- aggregation_delimiters = [{account: [40]}]
213
- field = :account
214
- expected = {account: [39]}
215
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
216
- expect(actual).to eq(expected)
217
- end
218
-
219
- it 'should merge two condition delimiter of different field with one aggregation delimiter of another field' do
220
- condition_delimiters = [{account: [39]}, {groups: ["a_group"]}]
221
- aggregation_delimiters = [{tags: ["a_tag"]}]
222
- field = :account
223
- expected = {account: [39]}
224
- actual = Elasticated.term_delimiter_factory.merge_delimiters(condition_delimiters, aggregation_delimiters, field)
225
- expect(actual).to eq(expected)
226
- end
227
-
228
- end
229
-
230
- describe DateDelimiterFactory do
231
- let(:empty_delimiter){ Elasticated::Delimiters::DateFieldDelimiter.new(field: :date) }
232
- let(:term_empty_delimiter){ Elasticated::Delimiters::TermFieldDelimiter.new(field: :date) }
233
-
234
- it "should create empty date delimiter from empty conditions" do
235
- query_delimiters = { conditions: [], aggregations: []}
236
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :date)
237
- actual = Elasticated.term_delimiter_factory.create(term_empty_delimiter, query_delimiters)
238
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
239
- end
240
-
241
- it 'should create empty date delimiter from empty condition delimiter definition and none aggregation delimiters' do
242
- query_delimiters = { conditions: [{}], aggregations: [] }
243
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :date)
244
- actual = Elasticated.term_delimiter_factory.create(term_empty_delimiter, query_delimiters)
245
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
246
-
247
- query_delimiters = { conditions: [{}, {}], aggregations: [] }
248
- actual = Elasticated.term_delimiter_factory.create(term_empty_delimiter, query_delimiters)
249
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
250
- end
251
-
252
- it 'should create date delimiter from condition delimiter' do
253
- query_delimiters = { conditions: [{date: ['2017-05-26']}], aggregations: [] }
254
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :date, values: ['2017-05-26'])
255
- actual = Elasticated.term_delimiter_factory.create(term_empty_delimiter, query_delimiters)
256
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
257
-
258
- query_delimiters = { conditions: [{date_since: '2017-05-26'}], aggregations: [] }
259
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26')
260
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters)
261
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
262
-
263
- query_delimiters = { conditions: [{date_until: '2017-05-26'}], aggregations: [] }
264
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_until: '2017-05-26')
265
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters)
266
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
267
-
268
- query_delimiters = { conditions: [{date_since: '2017-05-26', date_until: '2017-05-26'}], aggregations: [] }
269
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26', date_until: '2017-05-26')
270
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters)
271
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
272
- end
273
-
274
- it 'should create date delimiter from many condition delimiters' do
275
- query_delimiters = { conditions: [{date: ['2017-05-26']}, {date: ['2017-05-27']}, {date: ['2017-05-25']}], aggregations: [] }
276
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :date, values: ['2017-05-26', '2017-05-27', '2017-05-25'])
277
- actual = Elasticated.term_delimiter_factory.create(term_empty_delimiter, query_delimiters)
278
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
279
-
280
- query_delimiters = { conditions: [{date_since: '2017-05-26'}, {date_since: '2017-05-25'}, {date_since: '2017-05-27'}], aggregations: [] }
281
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-25')
282
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters)
283
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
284
-
285
- query_delimiters = { conditions: [{date_until: '2017-05-26'}, {date_until: '2017-05-25'}, {date_until: '2017-05-27'}], aggregations: [] }
286
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_until: '2017-05-27')
287
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters)
288
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
289
-
290
- query_delimiters = { conditions: [{date_since: '2017-05-25', date_until: '2017-05-26'}, {date_since: '2017-05-27', date_until: '2017-05-28'}], aggregations: [] }
291
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-25', date_until: '2017-05-28')
292
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters)
293
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
294
- end
295
-
296
- it 'should create date delimiter from aggregation delimiters' do
297
- options = {delimit_by: [:aggregations]}
298
- query_delimiters = { conditions: [{}], aggregations: [{date_since: '2017-05-26'}] }
299
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26')
300
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
301
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
302
-
303
- query_delimiters = { conditions: [], aggregations: [{date_since: '2017-05-26'}] }
304
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26')
305
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
306
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
307
-
308
- query_delimiters = { conditions: [], aggregations: [{date_until: '2017-05-26'}] }
309
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_until: '2017-05-26')
310
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
311
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
312
-
313
- query_delimiters = { conditions: [], aggregations: [{date_since: '2017-05-26', date_until: '2017-05-26'}] }
314
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26', date_until: '2017-05-26')
315
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
316
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
317
- end
318
-
319
- it 'should create date delimiter from many aggregation delimiters' do
320
- options = {delimit_by: [:aggregations]}
321
- query_delimiters = { conditions: [], aggregations: [{date: ['2017-05-26']}, {date: ['2017-05-27']}, {date: ['2017-05-25']}] }
322
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :date, values: ['2017-05-26', '2017-05-27', '2017-05-25'])
323
- actual = Elasticated.term_delimiter_factory.create(term_empty_delimiter, query_delimiters, options)
324
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
325
-
326
- query_delimiters = { conditions: [], aggregations: [{date_since: '2017-05-26'}, {date_since: '2017-05-25'}, {date_since: '2017-05-27'}] }
327
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-25')
328
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
329
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
330
-
331
- query_delimiters = { conditions: [], aggregations: [{date_until: '2017-05-26'}, {date_until: '2017-05-25'}, {date_until: '2017-05-27'}] }
332
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_until: '2017-05-27')
333
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
334
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
335
-
336
- query_delimiters = { conditions: [], aggregations: [{date_since: '2017-05-25', date_until: '2017-05-26'}, {date_since: '2017-05-27', date_until: '2017-05-28'}] }
337
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-25', date_until: '2017-05-28')
338
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
339
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
340
-
341
- query_delimiters = { conditions: [], aggregations: [{date_since: '2017-05-25'}, {date_until: '2017-05-28'}] }
342
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date)
343
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
344
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
345
- end
346
-
347
- it 'should create date delimiter from condition and aggregation delimiters' do
348
- options = {delimit_by: [:conditions, :aggregations]}
349
- query_delimiters = { conditions: [{date: ['2017-05-26']}, {date: ['2017-05-27']}], aggregations: [{date: ['2017-05-25']}] }
350
- expected = Elasticated::Delimiters::TermFieldDelimiter.new(field: :date, values: ['2017-05-26', '2017-05-27'])
351
- actual = Elasticated.term_delimiter_factory.create(term_empty_delimiter, query_delimiters, options)
352
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
353
-
354
- query_delimiters = { conditions: [{date_since: '2017-05-26'}], aggregations: [{date_since: '2017-05-25'}, {date_since: '2017-05-27'}] }
355
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26')
356
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
357
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
358
-
359
- query_delimiters = { conditions: [{date_until: '2017-05-26'}, {date_until: '2017-05-25'}], aggregations: [{date_until: '2017-05-27'}] }
360
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_until: '2017-05-26')
361
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
362
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
363
-
364
- query_delimiters = { conditions: [{date_since: '2017-05-25', date_until: '2017-05-26'}], aggregations: [{date_since: '2017-05-27', date_until: '2017-05-28'}] }
365
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-25', date_until: '2017-05-26')
366
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
367
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
368
-
369
- query_delimiters = { conditions: [{date_until: '2017-05-28'}], aggregations: [{date_since: '2017-05-25'}] }
370
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-25', date_until: '2017-05-28')
371
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
372
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
373
-
374
- query_delimiters = { conditions: [], aggregations: [{date_since: '2017-05-27', date_until: '2017-05-28'}] }
375
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-27', date_until: '2017-05-28')
376
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
377
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
378
-
379
- query_delimiters = { conditions: [{date_since: '2017-05-26'}], aggregations: [{date_since: '2017-05-27', date_until: '2017-05-28'}] }
380
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26', date_until: '2017-05-28')
381
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
382
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
383
-
384
- query_delimiters = { conditions: [{date_since: '2017-05-26'}], aggregations: [{date_since: '2017-05-27', date_until: '2017-05-28'}, {date_since: '2017-05-27'}] }
385
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26')
386
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
387
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
388
- end
389
-
390
- it 'should create date delimiter from condition and aggregation delimiters when condition delimiter has many different filters' do
391
- options = {delimit_by: [:conditions, :aggregations]}
392
- query_delimiters = { conditions: [{date_since: '2017-05-26'}, {date_until: '2017-05-31'}], aggregations: [{date_since: '2017-05-27', date_until: '2017-05-28'}, {date_since: '2017-05-27'}] }
393
- expected = Elasticated::Delimiters::DateFieldDelimiter.new(field: :date, date_since: '2017-05-26', date_until: '2017-05-31')
394
- actual = Elasticated.date_delimiter_factory.create(empty_delimiter, query_delimiters, options)
395
- expect(actual.build_strategy_params).to eq(expected.build_strategy_params)
396
- end
397
-
398
- end
399
- end