opensearch-dsl 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,288 @@
|
|
|
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
|
+
module OpenSearch
|
|
28
|
+
module DSL
|
|
29
|
+
|
|
30
|
+
# Provides DSL methods for building the search definition
|
|
31
|
+
# (queries, filters, aggregations, sorting, etc)
|
|
32
|
+
#
|
|
33
|
+
module Search
|
|
34
|
+
|
|
35
|
+
# Initialize a new Search object
|
|
36
|
+
#
|
|
37
|
+
# @example Building a search definition declaratively
|
|
38
|
+
#
|
|
39
|
+
# definition = search do
|
|
40
|
+
# query do
|
|
41
|
+
# match title: 'test'
|
|
42
|
+
# end
|
|
43
|
+
# end
|
|
44
|
+
# definition.to_hash
|
|
45
|
+
# => {:query=>{:match=>{:title=>"test"}}}
|
|
46
|
+
#
|
|
47
|
+
# @example Using the class imperatively
|
|
48
|
+
#
|
|
49
|
+
# definition = Search.new
|
|
50
|
+
# query = Queries::Match.new title: 'test'
|
|
51
|
+
# definition.query query
|
|
52
|
+
# definition.to_hash
|
|
53
|
+
# # => {:query=>{:match=>{:title=>"test"}}}
|
|
54
|
+
#
|
|
55
|
+
#
|
|
56
|
+
def search(*args, &block)
|
|
57
|
+
Search.new(*args, &block)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
extend self
|
|
61
|
+
|
|
62
|
+
# Wraps the whole search definition (queries, filters, aggregations, sorting, etc)
|
|
63
|
+
#
|
|
64
|
+
class Search
|
|
65
|
+
attr_reader :aggregations
|
|
66
|
+
|
|
67
|
+
def initialize(*args, &block)
|
|
68
|
+
@options = Options.new *args
|
|
69
|
+
block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# DSL method for building or accessing the `query` part of a search definition
|
|
73
|
+
#
|
|
74
|
+
# @return [self, {Query}]
|
|
75
|
+
#
|
|
76
|
+
def query(*args, &block)
|
|
77
|
+
case
|
|
78
|
+
when block
|
|
79
|
+
@query = Query.new(*args, &block)
|
|
80
|
+
self
|
|
81
|
+
when !args.empty?
|
|
82
|
+
@query = args.first
|
|
83
|
+
self
|
|
84
|
+
else
|
|
85
|
+
@query
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Set the query part of a search definition
|
|
90
|
+
#
|
|
91
|
+
def query=(value)
|
|
92
|
+
query value
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# DSL method for building the `filter` part of a search definition
|
|
96
|
+
#
|
|
97
|
+
# @return [self]
|
|
98
|
+
#
|
|
99
|
+
def filter(*args, &block)
|
|
100
|
+
case
|
|
101
|
+
when block
|
|
102
|
+
@filter = Filter.new(*args, &block)
|
|
103
|
+
self
|
|
104
|
+
when !args.empty?
|
|
105
|
+
@filter = args.first
|
|
106
|
+
self
|
|
107
|
+
else
|
|
108
|
+
@filter
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Set the filter part of a search definition
|
|
113
|
+
#
|
|
114
|
+
def filter=(value)
|
|
115
|
+
filter value
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# DSL method for building the `post_filter` part of a search definition
|
|
119
|
+
#
|
|
120
|
+
# @return [self]
|
|
121
|
+
#
|
|
122
|
+
def post_filter(*args, &block)
|
|
123
|
+
case
|
|
124
|
+
when block
|
|
125
|
+
@post_filter = Filter.new(*args, &block)
|
|
126
|
+
self
|
|
127
|
+
when !args.empty?
|
|
128
|
+
@post_filter = args.first
|
|
129
|
+
self
|
|
130
|
+
else
|
|
131
|
+
@post_filter
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Set the post_filter part of a search definition
|
|
136
|
+
#
|
|
137
|
+
def post_filter=(value)
|
|
138
|
+
post_filter value
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# DSL method for building the `aggregations` part of a search definition
|
|
142
|
+
#
|
|
143
|
+
# @return [self]
|
|
144
|
+
#
|
|
145
|
+
def aggregation(*args, &block)
|
|
146
|
+
@aggregations ||= AggregationsCollection.new
|
|
147
|
+
|
|
148
|
+
if block
|
|
149
|
+
@aggregations.update args.first => Aggregation.new(*args, &block)
|
|
150
|
+
else
|
|
151
|
+
name = args.shift
|
|
152
|
+
@aggregations.update name => args.shift
|
|
153
|
+
end
|
|
154
|
+
self
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Set the aggregations part of a search definition
|
|
158
|
+
#
|
|
159
|
+
def aggregations=(value)
|
|
160
|
+
@aggregations = value
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# DSL method for building the `highlight` part of a search definition
|
|
164
|
+
#
|
|
165
|
+
# @return [self]
|
|
166
|
+
#
|
|
167
|
+
def highlight(*args, &block)
|
|
168
|
+
if !args.empty? || block
|
|
169
|
+
@highlight = Highlight.new(*args, &block)
|
|
170
|
+
self
|
|
171
|
+
else
|
|
172
|
+
@highlight
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# DSL method for building the `sort` part of a search definition
|
|
177
|
+
#
|
|
178
|
+
# @return [self]
|
|
179
|
+
#
|
|
180
|
+
def sort(*args, &block)
|
|
181
|
+
if !args.empty? || block
|
|
182
|
+
@sort = Sort.new(*args, &block)
|
|
183
|
+
self
|
|
184
|
+
else
|
|
185
|
+
@sort
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Set the sort part of a search definition
|
|
190
|
+
#
|
|
191
|
+
def sort=(value)
|
|
192
|
+
@sort = value
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# DSL method for building the `stored_fields` part of a search definition
|
|
196
|
+
#
|
|
197
|
+
# @return [self]
|
|
198
|
+
#
|
|
199
|
+
def stored_fields(value=nil)
|
|
200
|
+
if value
|
|
201
|
+
@stored_fields = value
|
|
202
|
+
self
|
|
203
|
+
else
|
|
204
|
+
@stored_fields
|
|
205
|
+
end
|
|
206
|
+
end; alias_method :stored_fields=, :stored_fields
|
|
207
|
+
|
|
208
|
+
# DSL method for building the `size` part of a search definition
|
|
209
|
+
#
|
|
210
|
+
# @return [self]
|
|
211
|
+
#
|
|
212
|
+
def size(value=nil)
|
|
213
|
+
if value
|
|
214
|
+
@size = value
|
|
215
|
+
self
|
|
216
|
+
else
|
|
217
|
+
@size
|
|
218
|
+
end
|
|
219
|
+
end; alias_method :size=, :size
|
|
220
|
+
|
|
221
|
+
# DSL method for building the `from` part of a search definition
|
|
222
|
+
#
|
|
223
|
+
# @return [self]
|
|
224
|
+
#
|
|
225
|
+
def from(value=nil)
|
|
226
|
+
if value
|
|
227
|
+
@from = value
|
|
228
|
+
self
|
|
229
|
+
else
|
|
230
|
+
@from
|
|
231
|
+
end
|
|
232
|
+
end; alias_method :from=, :from
|
|
233
|
+
|
|
234
|
+
# DSL method for building the `suggest` part of a search definition
|
|
235
|
+
#
|
|
236
|
+
# @return [self]
|
|
237
|
+
#
|
|
238
|
+
def suggest(*args, &block)
|
|
239
|
+
if !args.empty? || block
|
|
240
|
+
@suggest ||= {}
|
|
241
|
+
key, options = args
|
|
242
|
+
@suggest.update key => Suggest.new(key, options, &block)
|
|
243
|
+
self
|
|
244
|
+
else
|
|
245
|
+
@suggest
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Set the suggest part of a search definition
|
|
250
|
+
#
|
|
251
|
+
def suggest=(value)
|
|
252
|
+
@suggest = value
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Delegates to the methods provided by the {Options} class
|
|
256
|
+
#
|
|
257
|
+
def method_missing(name, *args, &block)
|
|
258
|
+
if @options.respond_to? name
|
|
259
|
+
@options.__send__ name, *args, &block
|
|
260
|
+
self
|
|
261
|
+
else
|
|
262
|
+
super
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Converts the search definition to a Hash
|
|
267
|
+
#
|
|
268
|
+
# @return [Hash]
|
|
269
|
+
#
|
|
270
|
+
def to_hash
|
|
271
|
+
hash = {}
|
|
272
|
+
hash.update(query: @query.to_hash) if @query
|
|
273
|
+
hash.update(filter: @filter.to_hash) if @filter
|
|
274
|
+
hash.update(post_filter: @post_filter.to_hash) if @post_filter
|
|
275
|
+
hash.update(aggregations: @aggregations.reduce({}) { |sum,item| sum.update item.first => item.last.to_hash }) if @aggregations
|
|
276
|
+
hash.update(sort: @sort.to_hash) if @sort
|
|
277
|
+
hash.update(size: @size) if @size
|
|
278
|
+
hash.update(stored_fields: @stored_fields) if @stored_fields
|
|
279
|
+
hash.update(from: @from) if @from
|
|
280
|
+
hash.update(suggest: @suggest.reduce({}) { |sum,item| sum.update item.last.to_hash }) if @suggest
|
|
281
|
+
hash.update(highlight: @highlight.to_hash) if @highlight
|
|
282
|
+
hash.update(@options) unless @options.empty?
|
|
283
|
+
hash
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
module OpenSearch
|
|
28
|
+
module DSL
|
|
29
|
+
|
|
30
|
+
# Generic utility methods
|
|
31
|
+
#
|
|
32
|
+
module Utils
|
|
33
|
+
|
|
34
|
+
# Camelize an underscored string
|
|
35
|
+
#
|
|
36
|
+
# A lightweight version of ActiveSupport's `camelize`
|
|
37
|
+
#
|
|
38
|
+
# @example
|
|
39
|
+
# __camelize('query_string')
|
|
40
|
+
# # => 'QueryString'
|
|
41
|
+
#
|
|
42
|
+
# @api private
|
|
43
|
+
#
|
|
44
|
+
def __camelize(string)
|
|
45
|
+
string.to_s.split('_').map(&:capitalize).join
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
extend self
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
module OpenSearch
|
|
28
|
+
module DSL
|
|
29
|
+
VERSION = "0.1.0"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
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 'opensearch/dsl/version'
|
|
28
|
+
|
|
29
|
+
require 'opensearch/dsl/utils'
|
|
30
|
+
require 'opensearch/dsl/search/base_component'
|
|
31
|
+
require 'opensearch/dsl/search/base_compound_filter_component'
|
|
32
|
+
require 'opensearch/dsl/search/base_aggregation_component'
|
|
33
|
+
require 'opensearch/dsl/search/query'
|
|
34
|
+
require 'opensearch/dsl/search/filter'
|
|
35
|
+
require 'opensearch/dsl/search/aggregation'
|
|
36
|
+
require 'opensearch/dsl/search/highlight'
|
|
37
|
+
require 'opensearch/dsl/search/sort'
|
|
38
|
+
require 'opensearch/dsl/search/options'
|
|
39
|
+
require 'opensearch/dsl/search/suggest'
|
|
40
|
+
|
|
41
|
+
Dir[ File.expand_path('../dsl/search/queries/**/*.rb', __FILE__) ].each { |f| require f }
|
|
42
|
+
Dir[ File.expand_path('../dsl/search/filters/**/*.rb', __FILE__) ].each { |f| require f }
|
|
43
|
+
Dir[ File.expand_path('../dsl/search/aggregations/**/*.rb', __FILE__) ].each { |f| require f }
|
|
44
|
+
|
|
45
|
+
require 'opensearch/dsl/search'
|
|
46
|
+
|
|
47
|
+
module OpenSearch
|
|
48
|
+
|
|
49
|
+
# The main module, which can be included into your own class or namespace,
|
|
50
|
+
# to provide the DSL methods.
|
|
51
|
+
#
|
|
52
|
+
# @example
|
|
53
|
+
#
|
|
54
|
+
# include OpenSearch::DSL
|
|
55
|
+
#
|
|
56
|
+
# definition = search do
|
|
57
|
+
# query do
|
|
58
|
+
# match title: 'test'
|
|
59
|
+
# end
|
|
60
|
+
# end
|
|
61
|
+
#
|
|
62
|
+
# definition.to_hash
|
|
63
|
+
# # => { query: { match: { title: "test"} } }
|
|
64
|
+
#
|
|
65
|
+
# @see Search
|
|
66
|
+
#
|
|
67
|
+
module DSL
|
|
68
|
+
def self.included(base)
|
|
69
|
+
base.__send__ :include, OpenSearch::DSL::Search
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
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 'opensearch/dsl'
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
# coding: utf-8
|
|
28
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
29
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
30
|
+
require 'opensearch/dsl/version'
|
|
31
|
+
|
|
32
|
+
signing_key_path = File.expand_path("../gem-private_key.pem")
|
|
33
|
+
|
|
34
|
+
Gem::Specification.new do |s|
|
|
35
|
+
s.name = 'opensearch-dsl'
|
|
36
|
+
s.version = OpenSearch::DSL::VERSION
|
|
37
|
+
s.authors = ['Jayesh Hathila', 'Vamshi Vijay Nakkirtha', 'Vijayan Balasubramanian' , 'Yuvraj Jaiswal']
|
|
38
|
+
s.email = ['jayehh@amazon.com', 'vamshin@amazon.com', 'balasvij@amazon.com', 'jaiyuvra@amazon.com']
|
|
39
|
+
s.description = %q{A Ruby DSL builder for OpenSearch}
|
|
40
|
+
s.summary = s.description
|
|
41
|
+
s.homepage = 'https://opensearch.org/docs/latest/'
|
|
42
|
+
s.license = 'Apache-2.0'
|
|
43
|
+
s.metadata = {
|
|
44
|
+
'homepage_uri' => 'https://opensearch.org/docs/latest/',
|
|
45
|
+
'source_code_uri' => 'https://github.com/opensearch-project/opensearch-ruby/tree/main/opensearch-dsl',
|
|
46
|
+
'bug_tracker_uri' => 'https://github.com/opensearch-project/opensearch-ruby/issues'
|
|
47
|
+
}
|
|
48
|
+
s.files = `git ls-files`.split($/)
|
|
49
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
50
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
51
|
+
|
|
52
|
+
if $PROGRAM_NAME.end_with?("gem") && ARGV == ["build", __FILE__] && File.exist?(signing_key_path)
|
|
53
|
+
s.signing_key = signing_key_path
|
|
54
|
+
s.cert_chain = ['../certs/opensearch-rubygems.pem']
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
s.require_paths = ['lib']
|
|
58
|
+
|
|
59
|
+
s.extra_rdoc_files = [ 'README.md', 'LICENSE' ]
|
|
60
|
+
s.rdoc_options = [ '--charset=UTF-8' ]
|
|
61
|
+
|
|
62
|
+
s.required_ruby_version = '>= 2.4'
|
|
63
|
+
|
|
64
|
+
s.add_development_dependency 'bundler'
|
|
65
|
+
s.add_development_dependency 'rake', '~> 13'
|
|
66
|
+
|
|
67
|
+
s.add_development_dependency 'opensearch'
|
|
68
|
+
|
|
69
|
+
s.add_development_dependency 'cane'
|
|
70
|
+
s.add_development_dependency 'minitest', '~> 5'
|
|
71
|
+
s.add_development_dependency 'minitest-reporters', '~> 1'
|
|
72
|
+
s.add_development_dependency 'mocha'
|
|
73
|
+
s.add_development_dependency 'pry'
|
|
74
|
+
s.add_development_dependency 'shoulda-context'
|
|
75
|
+
s.add_development_dependency 'simplecov', '~> 0.17', '< 0.18'
|
|
76
|
+
s.add_development_dependency 'yard'
|
|
77
|
+
|
|
78
|
+
if defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
|
|
79
|
+
s.add_development_dependency 'test-unit', '~> 2'
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
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::Aggregations::Avg 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(avg: {})
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context '#initialize' do
|
|
43
|
+
|
|
44
|
+
let(:search) do
|
|
45
|
+
described_class.new(foo: 'bar')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'takes a hash' do
|
|
49
|
+
expect(search.to_hash).to eq(avg: { foo: 'bar' })
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|