opensearch-dsl 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/.gitignore +17 -0
- data/Gemfile +51 -0
- data/LICENSE +202 -0
- data/README.md +149 -0
- data/Rakefile +234 -0
- data/lib/opensearch/dsl/search/aggregation.rb +110 -0
- data/lib/opensearch/dsl/search/aggregations/avg.rb +51 -0
- data/lib/opensearch/dsl/search/aggregations/cardinality.rb +58 -0
- data/lib/opensearch/dsl/search/aggregations/children.rb +65 -0
- data/lib/opensearch/dsl/search/aggregations/composite.rb +68 -0
- data/lib/opensearch/dsl/search/aggregations/date_histogram.rb +66 -0
- data/lib/opensearch/dsl/search/aggregations/date_range.rb +60 -0
- data/lib/opensearch/dsl/search/aggregations/extended_stats.rb +50 -0
- data/lib/opensearch/dsl/search/aggregations/filter.rb +56 -0
- data/lib/opensearch/dsl/search/aggregations/filters.rb +61 -0
- data/lib/opensearch/dsl/search/aggregations/geo_bounds.rb +70 -0
- data/lib/opensearch/dsl/search/aggregations/geo_distance.rb +65 -0
- data/lib/opensearch/dsl/search/aggregations/geohash_grid.rb +61 -0
- data/lib/opensearch/dsl/search/aggregations/global.rb +54 -0
- data/lib/opensearch/dsl/search/aggregations/histogram.rb +61 -0
- data/lib/opensearch/dsl/search/aggregations/ip_range.rb +57 -0
- data/lib/opensearch/dsl/search/aggregations/max.rb +51 -0
- data/lib/opensearch/dsl/search/aggregations/min.rb +51 -0
- data/lib/opensearch/dsl/search/aggregations/missing.rb +61 -0
- data/lib/opensearch/dsl/search/aggregations/nested.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/percentile_ranks.rb +60 -0
- data/lib/opensearch/dsl/search/aggregations/percentiles.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/avg_bucket.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/bucket_script.rb +61 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/bucket_selector.rb +60 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/bucket_sort.rb +114 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/cumulative_sum.rb +58 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/derivative.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/extended_stats_bucket.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/max_bucket.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/min_bucket.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/moving_avg.rb +67 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/percentiles_bucket.rb +61 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/serial_diff.rb +61 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/stats_bucket.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/pipeline/sum_bucket.rb +59 -0
- data/lib/opensearch/dsl/search/aggregations/range.rb +79 -0
- data/lib/opensearch/dsl/search/aggregations/reverse_nested.rb +63 -0
- data/lib/opensearch/dsl/search/aggregations/scripted_metric.rb +65 -0
- data/lib/opensearch/dsl/search/aggregations/significant_terms.rb +71 -0
- data/lib/opensearch/dsl/search/aggregations/stats.rb +63 -0
- data/lib/opensearch/dsl/search/aggregations/sum.rb +51 -0
- data/lib/opensearch/dsl/search/aggregations/terms.rb +68 -0
- data/lib/opensearch/dsl/search/aggregations/top_hits.rb +61 -0
- data/lib/opensearch/dsl/search/aggregations/value_count.rb +51 -0
- data/lib/opensearch/dsl/search/base_aggregation_component.rb +90 -0
- data/lib/opensearch/dsl/search/base_component.rb +193 -0
- data/lib/opensearch/dsl/search/base_compound_filter_component.rb +123 -0
- data/lib/opensearch/dsl/search/filter.rb +81 -0
- data/lib/opensearch/dsl/search/filters/and.rb +71 -0
- data/lib/opensearch/dsl/search/filters/bool.rb +105 -0
- data/lib/opensearch/dsl/search/filters/exists.rb +58 -0
- data/lib/opensearch/dsl/search/filters/geo_bounding_box.rb +71 -0
- data/lib/opensearch/dsl/search/filters/geo_distance.rb +83 -0
- data/lib/opensearch/dsl/search/filters/geo_distance_range.rb +58 -0
- data/lib/opensearch/dsl/search/filters/geo_polygon.rb +67 -0
- data/lib/opensearch/dsl/search/filters/geo_shape.rb +61 -0
- data/lib/opensearch/dsl/search/filters/geohash_cell.rb +72 -0
- data/lib/opensearch/dsl/search/filters/has_child.rb +100 -0
- data/lib/opensearch/dsl/search/filters/has_parent.rb +99 -0
- data/lib/opensearch/dsl/search/filters/ids.rb +58 -0
- data/lib/opensearch/dsl/search/filters/indices.rb +103 -0
- data/lib/opensearch/dsl/search/filters/limit.rb +57 -0
- data/lib/opensearch/dsl/search/filters/match_all.rb +54 -0
- data/lib/opensearch/dsl/search/filters/missing.rb +60 -0
- data/lib/opensearch/dsl/search/filters/nested.rb +93 -0
- data/lib/opensearch/dsl/search/filters/not.rb +99 -0
- data/lib/opensearch/dsl/search/filters/or.rb +71 -0
- data/lib/opensearch/dsl/search/filters/prefix.rb +55 -0
- data/lib/opensearch/dsl/search/filters/query.rb +80 -0
- data/lib/opensearch/dsl/search/filters/range.rb +65 -0
- data/lib/opensearch/dsl/search/filters/regexp.rb +60 -0
- data/lib/opensearch/dsl/search/filters/script.rb +58 -0
- data/lib/opensearch/dsl/search/filters/term.rb +57 -0
- data/lib/opensearch/dsl/search/filters/terms.rb +58 -0
- data/lib/opensearch/dsl/search/filters/type.rb +60 -0
- data/lib/opensearch/dsl/search/highlight.rb +117 -0
- data/lib/opensearch/dsl/search/options.rb +81 -0
- data/lib/opensearch/dsl/search/queries/bool.rb +111 -0
- data/lib/opensearch/dsl/search/queries/boosting.rb +59 -0
- data/lib/opensearch/dsl/search/queries/common.rb +64 -0
- data/lib/opensearch/dsl/search/queries/constant_score.rb +92 -0
- data/lib/opensearch/dsl/search/queries/dis_max.rb +61 -0
- data/lib/opensearch/dsl/search/queries/exists.rb +69 -0
- data/lib/opensearch/dsl/search/queries/filtered.rb +103 -0
- data/lib/opensearch/dsl/search/queries/function_score.rb +128 -0
- data/lib/opensearch/dsl/search/queries/fuzzy.rb +71 -0
- data/lib/opensearch/dsl/search/queries/fuzzy_like_this.rb +63 -0
- data/lib/opensearch/dsl/search/queries/fuzzy_like_this_field.rb +62 -0
- data/lib/opensearch/dsl/search/queries/geo_shape.rb +56 -0
- data/lib/opensearch/dsl/search/queries/has_child.rb +84 -0
- data/lib/opensearch/dsl/search/queries/has_parent.rb +84 -0
- data/lib/opensearch/dsl/search/queries/ids.rb +54 -0
- data/lib/opensearch/dsl/search/queries/indices.rb +60 -0
- data/lib/opensearch/dsl/search/queries/match.rb +69 -0
- data/lib/opensearch/dsl/search/queries/match_all.rb +52 -0
- data/lib/opensearch/dsl/search/queries/match_phrase.rb +58 -0
- data/lib/opensearch/dsl/search/queries/match_phrase_prefix.rb +57 -0
- data/lib/opensearch/dsl/search/queries/more_like_this.rb +90 -0
- data/lib/opensearch/dsl/search/queries/multi_match.rb +71 -0
- data/lib/opensearch/dsl/search/queries/nested.rb +82 -0
- data/lib/opensearch/dsl/search/queries/prefix.rb +56 -0
- data/lib/opensearch/dsl/search/queries/query_string.rb +77 -0
- data/lib/opensearch/dsl/search/queries/range.rb +73 -0
- data/lib/opensearch/dsl/search/queries/regexp.rb +57 -0
- data/lib/opensearch/dsl/search/queries/simple_query_string.rb +66 -0
- data/lib/opensearch/dsl/search/queries/span_first.rb +54 -0
- data/lib/opensearch/dsl/search/queries/span_multi.rb +54 -0
- data/lib/opensearch/dsl/search/queries/span_near.rb +58 -0
- data/lib/opensearch/dsl/search/queries/span_not.rb +59 -0
- data/lib/opensearch/dsl/search/queries/span_or.rb +54 -0
- data/lib/opensearch/dsl/search/queries/span_term.rb +52 -0
- data/lib/opensearch/dsl/search/queries/template.rb +57 -0
- data/lib/opensearch/dsl/search/queries/term.rb +52 -0
- data/lib/opensearch/dsl/search/queries/terms.rb +53 -0
- data/lib/opensearch/dsl/search/queries/top_children.rb +84 -0
- data/lib/opensearch/dsl/search/queries/wildcard.rb +56 -0
- data/lib/opensearch/dsl/search/query.rb +80 -0
- data/lib/opensearch/dsl/search/sort.rb +84 -0
- data/lib/opensearch/dsl/search/suggest.rb +53 -0
- data/lib/opensearch/dsl/search.rb +288 -0
- data/lib/opensearch/dsl/utils.rb +51 -0
- data/lib/opensearch/dsl/version.rb +31 -0
- data/lib/opensearch/dsl.rb +72 -0
- data/lib/opensearch-dsl.rb +27 -0
- data/opensearch-dsl.gemspec +81 -0
- data/spec/opensearch/dsl/search/aggregations/avg_spec.rb +52 -0
- data/spec/opensearch/dsl/search/aggregations/cardinality_spec.rb +119 -0
- data/spec/opensearch/dsl/search/aggregations/children_spec.rb +75 -0
- data/spec/opensearch/dsl/search/aggregations/composite_spec.rb +108 -0
- data/spec/opensearch/dsl/search/aggregations/date_histogram_spec.rb +198 -0
- data/spec/opensearch/dsl/search/aggregations/date_range_spec.rb +98 -0
- data/spec/opensearch/dsl/search/aggregations/extended_stats_spec.rb +52 -0
- data/spec/opensearch/dsl/search/aggregations/filter_spec.rb +57 -0
- data/spec/opensearch/dsl/search/aggregations/filters_spec.rb +98 -0
- data/spec/opensearch/dsl/search/aggregations/geo_bounds_spec.rb +86 -0
- data/spec/opensearch/dsl/search/aggregations/geo_distance_spec.rb +122 -0
- data/spec/opensearch/dsl/search/aggregations/geo_grid_spec.rb +109 -0
- data/spec/opensearch/dsl/search/aggregations/global_spec.rb +71 -0
- data/spec/opensearch/dsl/search/aggregations/historgram_spec.rb +131 -0
- data/spec/opensearch/dsl/search/aggregations/ip_range_spec.rb +102 -0
- data/spec/opensearch/dsl/search/aggregations/max_spec.rb +52 -0
- data/spec/opensearch/dsl/search/aggregations/min_spec.rb +52 -0
- data/spec/opensearch/dsl/search/aggregations/missing_spec.rb +90 -0
- data/spec/opensearch/dsl/search/aggregations/nested_spec.rb +95 -0
- data/spec/opensearch/dsl/search/aggregations/percentile_ranks_spec.rb +135 -0
- data/spec/opensearch/dsl/search/aggregations/percentiles_spec.rb +134 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/avg_bucket_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/bucket_script_spec.rb +108 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/bucket_selector_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/bucket_sort_spec.rb +113 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/cumulative_sum_spec.rb +86 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/derivative_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/extended_stats_bucket_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/max_bucket_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/min_bucket_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/moving_avg_test_spec.rb +141 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/percentiles_bucket_spec.rb +108 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/serial_diff_spec.rb +108 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/stats_bucket_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/pipeline/sum_bucket_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/range_spec.rb +128 -0
- data/spec/opensearch/dsl/search/aggregations/reverse_nested_spec.rb +41 -0
- data/spec/opensearch/dsl/search/aggregations/scripted_metric_spec.rb +130 -0
- data/spec/opensearch/dsl/search/aggregations/significant_terms_spec.rb +185 -0
- data/spec/opensearch/dsl/search/aggregations/stats_spec.rb +65 -0
- data/spec/opensearch/dsl/search/aggregations/sum_spec.rb +52 -0
- data/spec/opensearch/dsl/search/aggregations/terms_spec.rb +174 -0
- data/spec/opensearch/dsl/search/aggregations/top_hits_spec.rb +97 -0
- data/spec/opensearch/dsl/search/aggregations/value_count_spec.rb +52 -0
- data/spec/opensearch/dsl/search/filters/and_spec.rb +83 -0
- data/spec/opensearch/dsl/search/filters/bool_spec.rb +208 -0
- data/spec/opensearch/dsl/search/filters/exists_spec.rb +75 -0
- data/spec/opensearch/dsl/search/filters/geo_bounding_box_spec.rb +153 -0
- data/spec/opensearch/dsl/search/filters/geo_distance_range_spec.rb +112 -0
- data/spec/opensearch/dsl/search/filters/geo_distance_spec.rb +135 -0
- data/spec/opensearch/dsl/search/filters/geo_polygon_spec.rb +75 -0
- data/spec/opensearch/dsl/search/filters/geo_shape_spec.rb +86 -0
- data/spec/opensearch/dsl/search/filters/geohash_cell_spec.rb +108 -0
- data/spec/opensearch/dsl/search/filters/has_child_spec.rb +148 -0
- data/spec/opensearch/dsl/search/filters/has_parent_spec.rb +137 -0
- data/spec/opensearch/dsl/search/filters/ids_spec.rb +87 -0
- data/spec/opensearch/dsl/search/filters/indices_spec.rb +118 -0
- data/spec/opensearch/dsl/search/filters/limit_spec.rb +75 -0
- data/spec/opensearch/dsl/search/filters/match_all_spec.rb +41 -0
- data/spec/opensearch/dsl/search/filters/missing_spec.rb +75 -0
- data/spec/opensearch/dsl/search/filters/nested_spec.rb +100 -0
- data/spec/opensearch/dsl/search/filters/not_spec.rb +68 -0
- data/spec/opensearch/dsl/search/filters/or_spec.rb +84 -0
- data/spec/opensearch/dsl/search/filters/prefix_spec.rb +55 -0
- data/spec/opensearch/dsl/search/filters/query_spec.rb +68 -0
- data/spec/opensearch/dsl/search/filters/range_spec.rb +120 -0
- data/spec/opensearch/dsl/search/filters/regexp_spec.rb +97 -0
- data/spec/opensearch/dsl/search/filters/script_spec.rb +86 -0
- data/spec/opensearch/dsl/search/filters/term_spec.rb +66 -0
- data/spec/opensearch/dsl/search/filters/terms_spec.rb +55 -0
- data/spec/opensearch/dsl/search/filters/type_spec.rb +75 -0
- data/spec/opensearch/dsl/search/queries/bool_spec.rb +276 -0
- data/spec/opensearch/dsl/search/queries/boosting_spec.rb +99 -0
- data/spec/opensearch/dsl/search/queries/common_spec.rb +141 -0
- data/spec/opensearch/dsl/search/queries/constant_score_spec.rb +99 -0
- data/spec/opensearch/dsl/search/queries/dis_max_spec.rb +97 -0
- data/spec/opensearch/dsl/search/queries/exists_spec.rb +75 -0
- data/spec/opensearch/dsl/search/queries/filtered_spec.rb +102 -0
- data/spec/opensearch/dsl/search/queries/function_score_spec.rb +173 -0
- data/spec/opensearch/dsl/search/queries/fuzzy_like_this_field_spec.rb +141 -0
- data/spec/opensearch/dsl/search/queries/fuzzy_like_this_spec.rb +143 -0
- data/spec/opensearch/dsl/search/queries/fuzzy_spec.rb +119 -0
- data/spec/opensearch/dsl/search/queries/geo_shape_spec.rb +86 -0
- data/spec/opensearch/dsl/search/queries/has_child_spec.rb +135 -0
- data/spec/opensearch/dsl/search/queries/has_parent_spec.rb +109 -0
- data/spec/opensearch/dsl/search/queries/ids_spec.rb +87 -0
- data/spec/opensearch/dsl/search/queries/indices_spec.rb +98 -0
- data/spec/opensearch/dsl/search/queries/match_all_spec.rb +75 -0
- data/spec/opensearch/dsl/search/queries/match_phrase_prefix_spec.rb +112 -0
- data/spec/opensearch/dsl/search/queries/match_phrase_spec.rb +123 -0
- data/spec/opensearch/dsl/search/queries/match_spec.rb +116 -0
- data/spec/opensearch/dsl/search/queries/more_like_this_spec.rb +96 -0
- data/spec/opensearch/dsl/search/queries/multi_match_spec.rb +83 -0
- data/spec/opensearch/dsl/search/queries/nested_spec.rb +107 -0
- data/spec/opensearch/dsl/search/queries/prefix_spec.rb +79 -0
- data/spec/opensearch/dsl/search/queries/query_string_spec.rb +98 -0
- data/spec/opensearch/dsl/search/queries/range_spec.rb +87 -0
- data/spec/opensearch/dsl/search/queries/regexp_spec.rb +91 -0
- data/spec/opensearch/dsl/search/queries/simple_query_string_spec.rb +83 -0
- data/spec/opensearch/dsl/search/queries/span_first_spec.rb +78 -0
- data/spec/opensearch/dsl/search/queries/span_multi_spec.rb +78 -0
- data/spec/opensearch/dsl/search/queries/span_near_spec.rb +81 -0
- data/spec/opensearch/dsl/search/queries/span_not_spec.rb +82 -0
- data/spec/opensearch/dsl/search/queries/span_or_spec.rb +78 -0
- data/spec/opensearch/dsl/search/queries/span_term_spec.rb +55 -0
- data/spec/opensearch/dsl/search/queries/template_spec.rb +93 -0
- data/spec/opensearch/dsl/search/queries/term_spec.rb +66 -0
- data/spec/opensearch/dsl/search/queries/terms_spec.rb +55 -0
- data/spec/opensearch/dsl/search/queries/top_children_spec.rb +102 -0
- data/spec/opensearch/dsl/search/queries/wildcard_spec.rb +90 -0
- data/spec/spec_helper.rb +33 -0
- data/test/integration/search_aggregation_children_test.rb +91 -0
- data/test/integration/search_aggregation_geo_test.rb +111 -0
- data/test/integration/search_aggregation_nested_test.rb +128 -0
- data/test/integration/search_aggregations_test.rb +287 -0
- data/test/integration/search_filters_test.rb +290 -0
- data/test/integration/search_options_test.rb +54 -0
- data/test/integration/search_query_test.rb +99 -0
- data/test/integration/search_size_from_test.rb +71 -0
- data/test/integration/search_sort_test.rb +58 -0
- data/test/integration/search_suggest_test.rb +103 -0
- data/test/integration/search_test.rb +82 -0
- data/test/test_helper.rb +95 -0
- data/test/unit/dsl_test.rb +44 -0
- data/test/unit/search_aggregation_test.rb +98 -0
- data/test/unit/search_base_aggregation_component_test.rb +67 -0
- data/test/unit/search_base_component_test.rb +212 -0
- data/test/unit/search_filter_test.rb +87 -0
- data/test/unit/search_highlight_test.rb +103 -0
- data/test/unit/search_options_test.rb +114 -0
- data/test/unit/search_query_test.rb +91 -0
- data/test/unit/search_size_from_test.rb +69 -0
- data/test/unit/search_sort_test.rb +91 -0
- data/test/unit/search_suggest_test.rb +46 -0
- data/test/unit/search_test.rb +270 -0
- data/test/unit/utils_test.rb +47 -0
- data.tar.gz.sig +3 -0
- metadata +654 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'spec_helper'
|
28
|
+
|
29
|
+
describe OpenSearch::DSL::Search::Filters::Term do
|
30
|
+
|
31
|
+
let(:search) do
|
32
|
+
described_class.new
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#to_hash' do
|
36
|
+
|
37
|
+
it 'can be converted to a hash' do
|
38
|
+
expect(search.to_hash).to eq(term: {})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#initialize' do
|
43
|
+
|
44
|
+
context 'when a scalar is specified' do
|
45
|
+
|
46
|
+
let(:search) do
|
47
|
+
described_class.new(message: 'test')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'sets the value' do
|
51
|
+
expect(search.to_hash).to eq(term: { message: 'test' })
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when a hash is specified' do
|
56
|
+
|
57
|
+
let(:search) do
|
58
|
+
described_class.new(message: { query: 'test' })
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'sets the value' do
|
62
|
+
expect(search.to_hash).to eq(term: { message: { query: 'test' } })
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'spec_helper'
|
28
|
+
|
29
|
+
describe OpenSearch::DSL::Search::Filters::Terms do
|
30
|
+
|
31
|
+
let(:search) do
|
32
|
+
described_class.new
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#to_hash' do
|
36
|
+
|
37
|
+
it 'can be converted to a hash' do
|
38
|
+
expect(search.to_hash).to eq(terms: {})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#initialize' do
|
43
|
+
|
44
|
+
context 'when a hash is specified' do
|
45
|
+
|
46
|
+
let(:search) do
|
47
|
+
described_class.new(foo: ['abc', 'xyz'])
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'sets the value' do
|
51
|
+
expect(search.to_hash).to eq(terms: { foo: ['abc', 'xyz'] })
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'spec_helper'
|
28
|
+
|
29
|
+
describe OpenSearch::DSL::Search::Filters::Type do
|
30
|
+
|
31
|
+
let(:search) do
|
32
|
+
described_class.new
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#to_hash' do
|
36
|
+
|
37
|
+
it 'can be converted to a hash' do
|
38
|
+
expect(search.to_hash).to eq(type: {})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when options methods are called' do
|
43
|
+
|
44
|
+
let(:search) do
|
45
|
+
described_class.new(:foo)
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#value' do
|
49
|
+
|
50
|
+
before do
|
51
|
+
search.value('bar')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'applies the option' do
|
55
|
+
expect(search.to_hash[:type][:foo][:value]).to eq('bar')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#initialize' do
|
61
|
+
|
62
|
+
context 'when a block is provided' do
|
63
|
+
|
64
|
+
let(:search) do
|
65
|
+
described_class.new(:foo) do
|
66
|
+
value 'bar'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'executes the block' do
|
71
|
+
expect(search.to_hash).to eq(type: { foo: { value: 'bar' } })
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,276 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'spec_helper'
|
28
|
+
|
29
|
+
describe OpenSearch::DSL::Search::Queries::Bool do
|
30
|
+
|
31
|
+
describe '#to_hash' do
|
32
|
+
|
33
|
+
let(:search) do
|
34
|
+
described_class.new
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'can be converted to a hash' do
|
38
|
+
expect(search.to_hash).to eq(bool: {})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#initialize' do
|
43
|
+
|
44
|
+
context 'when an object instance is provided' do
|
45
|
+
|
46
|
+
let(:search) do
|
47
|
+
described_class.new.must(OpenSearch::DSL::Search::Queries::Match.new foo: 'bar')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'applies the condition' do
|
51
|
+
expect(search.to_hash).to eq(bool: {must: [ {match: { foo: 'bar' }} ] })
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when multiple option methods are called' do
|
55
|
+
|
56
|
+
let(:search) do
|
57
|
+
described_class.new do
|
58
|
+
should(OpenSearch::DSL::Search::Queries::Term.new(tag: 'wow'))
|
59
|
+
should(OpenSearch::DSL::Search::Queries::Term.new(tag: 'opensearch'))
|
60
|
+
|
61
|
+
minimum_should_match 1
|
62
|
+
boost 1.0
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'defines all the options' do
|
67
|
+
expect(search.to_hash).to eq(bool: {
|
68
|
+
minimum_should_match: 1,
|
69
|
+
boost: 1.0,
|
70
|
+
should: [ {term: { tag: 'wow' }}, {term: { tag: 'opensearch' }} ]})
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when multiple conditions are provided' do
|
75
|
+
|
76
|
+
let(:search) do
|
77
|
+
described_class.new do
|
78
|
+
must(OpenSearch::DSL::Search::Queries::Match.new foo: 'bar')
|
79
|
+
must(OpenSearch::DSL::Search::Queries::Match.new moo: 'bam')
|
80
|
+
|
81
|
+
should(OpenSearch::DSL::Search::Queries::Match.new xoo: 'bax')
|
82
|
+
should(OpenSearch::DSL::Search::Queries::Match.new zoo: 'baz')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'applies each condition' do
|
87
|
+
expect(search.to_hash).to eq(bool:
|
88
|
+
{ must: [ {match: { foo: 'bar' }}, {match: { moo: 'bam' }} ],
|
89
|
+
should: [ {match: { xoo: 'bax' }}, {match: { zoo: 'baz' }} ]
|
90
|
+
})
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when #to_hash is called more than once' do
|
94
|
+
|
95
|
+
it 'does not alter the hash' do
|
96
|
+
expect(search.to_hash).to eq(search.to_hash)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when a block is provided' do
|
103
|
+
|
104
|
+
let(:search) do
|
105
|
+
described_class.new do
|
106
|
+
must { match foo: 'bar' }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'executes the block' do
|
111
|
+
expect(search.to_hash).to eq(bool: {must: [ {match: { foo: 'bar' }} ] })
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'when multiple option methods are called' do
|
115
|
+
|
116
|
+
let(:search) do
|
117
|
+
described_class.new do
|
118
|
+
should { term tag: 'wow' }
|
119
|
+
should { term tag: 'opensearch' }
|
120
|
+
|
121
|
+
minimum_should_match 1
|
122
|
+
boost 1.0
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'defines all the options' do
|
127
|
+
expect(search.to_hash).to eq(bool: {
|
128
|
+
minimum_should_match: 1,
|
129
|
+
boost: 1.0,
|
130
|
+
should: [ {term: { tag: 'wow' }}, {term: { tag: 'opensearch' }} ]})
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'when multiple conditions are provided' do
|
135
|
+
|
136
|
+
let(:search) do
|
137
|
+
described_class.new do
|
138
|
+
must do
|
139
|
+
match foo: 'bar'
|
140
|
+
end
|
141
|
+
|
142
|
+
must do
|
143
|
+
match moo: 'bam'
|
144
|
+
end
|
145
|
+
|
146
|
+
should do
|
147
|
+
match xoo: 'bax'
|
148
|
+
end
|
149
|
+
|
150
|
+
should do
|
151
|
+
match zoo: 'baz'
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'applies each condition' do
|
157
|
+
expect(search.to_hash).to eq(bool:
|
158
|
+
{ must: [ {match: { foo: 'bar' }}, {match: { moo: 'bam' }} ],
|
159
|
+
should: [ {match: { xoo: 'bax' }}, {match: { zoo: 'baz' }} ]
|
160
|
+
})
|
161
|
+
end
|
162
|
+
|
163
|
+
context 'when #to_hash is called more than once' do
|
164
|
+
|
165
|
+
it 'does not alter the hash' do
|
166
|
+
expect(search.to_hash).to eq(search.to_hash)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'when options methods are called' do
|
174
|
+
|
175
|
+
let(:search) do
|
176
|
+
described_class.new
|
177
|
+
end
|
178
|
+
|
179
|
+
before do
|
180
|
+
search.must { match foo: 'bar' }
|
181
|
+
search.must { match moo: 'bam' }
|
182
|
+
search.should { match xoo: 'bax' }
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'applies the option' do
|
186
|
+
expect(search.to_hash).to eq(bool: { must: [ {match: { foo: 'bar' }}, {match: { moo: 'bam' }} ],
|
187
|
+
should: [ {match: { xoo: 'bax' }} ] })
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'when the filter method is called multiple times' do
|
192
|
+
|
193
|
+
let(:search) do
|
194
|
+
described_class.new
|
195
|
+
end
|
196
|
+
|
197
|
+
before do
|
198
|
+
search.filter { term foo: 'bar' }
|
199
|
+
search.filter { term zoo: 'baz' }
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'combines the filter clauses' do
|
203
|
+
expect(search.to_hash).to eq(bool:
|
204
|
+
{ filter: [
|
205
|
+
{ term: { foo: "bar"}},
|
206
|
+
{ term: { zoo: "baz"}}
|
207
|
+
] })
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'when methods are chained' do
|
212
|
+
|
213
|
+
let(:search) do
|
214
|
+
described_class.new
|
215
|
+
end
|
216
|
+
|
217
|
+
before do
|
218
|
+
search.must { match foo: 'bar' }.must { match moo: 'bam' }.should { match xoo: 'bax' }
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'applies the option' do
|
222
|
+
expect(search.to_hash).to eq(bool: { must: [ {match: { foo: 'bar' }}, {match: { moo: 'bam' }} ],
|
223
|
+
should: [ {match: { xoo: 'bax' }} ] })
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe '#filter' do
|
228
|
+
|
229
|
+
context 'when a block is used to define the filter' do
|
230
|
+
|
231
|
+
let(:search) do
|
232
|
+
described_class.new do
|
233
|
+
filter do
|
234
|
+
term foo: 'Foo!'
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'applies the filter' do
|
240
|
+
expect(search.to_hash).to eq(bool: { filter: [{ term: { foo: 'Foo!' } }] })
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context 'when a filter is passed as an argument' do
|
245
|
+
|
246
|
+
context 'when the filter is a hash' do
|
247
|
+
|
248
|
+
let(:search) do
|
249
|
+
described_class.new do
|
250
|
+
filter(term: { foo: 'Foo!' })
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'applies the filter' do
|
255
|
+
expect(search.to_hash).to eq(bool: { filter: [{ term: { foo: 'Foo!' } }] })
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'when the filter is a `OpenSearch::DSL::Search::Filter` object' do
|
260
|
+
|
261
|
+
let(:search) do
|
262
|
+
filter_object = OpenSearch::DSL::Search::Filter.new do
|
263
|
+
term bar: 'Bar!'
|
264
|
+
end
|
265
|
+
described_class.new do
|
266
|
+
filter(filter_object)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'applies the filter' do
|
271
|
+
expect(search.to_hash).to eq(bool: { filter: [{ term: { bar: 'Bar!' } }] })
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'spec_helper'
|
28
|
+
|
29
|
+
describe OpenSearch::DSL::Search::Queries::Boosting do
|
30
|
+
|
31
|
+
describe '#to_hash' do
|
32
|
+
|
33
|
+
let(:search) do
|
34
|
+
described_class.new
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'can be converted to a hash' do
|
38
|
+
expect(search.to_hash).to eq(boosting: {})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when options methods are called' do
|
43
|
+
|
44
|
+
let(:search) do
|
45
|
+
described_class.new
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#positive' do
|
49
|
+
|
50
|
+
before do
|
51
|
+
search.positive('bar')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'applies the option' do
|
55
|
+
expect(search.to_hash[:boosting][:positive]).to eq('bar')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#negative' do
|
60
|
+
|
61
|
+
before do
|
62
|
+
search.negative('bar')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'applies the option' do
|
66
|
+
expect(search.to_hash[:boosting][:negative]).to eq('bar')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#negative_boost' do
|
71
|
+
|
72
|
+
before do
|
73
|
+
search.negative_boost('bar')
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'applies the option' do
|
77
|
+
expect(search.to_hash[:boosting][:negative_boost]).to eq('bar')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#initialize' do
|
83
|
+
|
84
|
+
context 'when a block is provided' do
|
85
|
+
|
86
|
+
let(:search) do
|
87
|
+
described_class.new do
|
88
|
+
positive foo: 'bar'
|
89
|
+
negative moo: 'xoo'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'executes the block' do
|
94
|
+
expect(search.to_hash[:boosting][:positive][:foo]).to eq('bar')
|
95
|
+
expect(search.to_hash[:boosting][:negative][:moo]).to eq('xoo')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
#
|
3
|
+
# The OpenSearch Contributors require contributions made to
|
4
|
+
# this file be licensed under the Apache-2.0 license or a
|
5
|
+
# compatible open source license.
|
6
|
+
#
|
7
|
+
# Modifications Copyright OpenSearch Contributors. See
|
8
|
+
# GitHub history for details.
|
9
|
+
#
|
10
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
11
|
+
# license agreements. See the NOTICE file distributed with
|
12
|
+
# this work for additional information regarding copyright
|
13
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
14
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
15
|
+
# not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing,
|
21
|
+
# software distributed under the License is distributed on an
|
22
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
23
|
+
# KIND, either express or implied. See the License for the
|
24
|
+
# specific language governing permissions and limitations
|
25
|
+
# under the License.
|
26
|
+
|
27
|
+
require 'spec_helper'
|
28
|
+
|
29
|
+
describe OpenSearch::DSL::Search::Queries::Common do
|
30
|
+
|
31
|
+
describe '#to_hash' do
|
32
|
+
|
33
|
+
let(:search) do
|
34
|
+
described_class.new
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'can be converted to a hash' do
|
38
|
+
expect(search.to_hash).to eq(common: {})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when options methods are called' do
|
43
|
+
|
44
|
+
let(:search) do
|
45
|
+
described_class.new
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#query' do
|
49
|
+
|
50
|
+
before do
|
51
|
+
search.query('bar')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'applies the option' do
|
55
|
+
expect(search.to_hash[:common][:query]).to eq('bar')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#cutoff_frequency' do
|
60
|
+
|
61
|
+
before do
|
62
|
+
search.cutoff_frequency('bar')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'applies the option' do
|
66
|
+
expect(search.to_hash[:common][:cutoff_frequency]).to eq('bar')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#low_freq_operator' do
|
71
|
+
|
72
|
+
before do
|
73
|
+
search.low_freq_operator('bar')
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'applies the option' do
|
77
|
+
expect(search.to_hash[:common][:low_freq_operator]).to eq('bar')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#minimum_should_match' do
|
82
|
+
|
83
|
+
before do
|
84
|
+
search.minimum_should_match('bar')
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'applies the option' do
|
88
|
+
expect(search.to_hash[:common][:minimum_should_match]).to eq('bar')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#boost' do
|
93
|
+
|
94
|
+
before do
|
95
|
+
search.boost('bar')
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'applies the option' do
|
99
|
+
expect(search.to_hash[:common][:boost]).to eq('bar')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#analyzer' do
|
104
|
+
|
105
|
+
before do
|
106
|
+
search.analyzer('bar')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'applies the option' do
|
110
|
+
expect(search.to_hash[:common][:analyzer]).to eq('bar')
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#disable_coord' do
|
115
|
+
|
116
|
+
before do
|
117
|
+
search.disable_coord('bar')
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'applies the option' do
|
121
|
+
expect(search.to_hash[:common][:disable_coord]).to eq('bar')
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe '#initialize' do
|
127
|
+
|
128
|
+
context 'when a block is provided' do
|
129
|
+
|
130
|
+
let(:search) do
|
131
|
+
described_class.new do
|
132
|
+
query 'bar'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'executes the block' do
|
137
|
+
expect(search.to_hash[:common][:query]).to eq('bar')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|