opensearch-dsl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (272) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/.gitignore +17 -0
  4. data/Gemfile +51 -0
  5. data/LICENSE +202 -0
  6. data/README.md +149 -0
  7. data/Rakefile +234 -0
  8. data/lib/opensearch/dsl/search/aggregation.rb +110 -0
  9. data/lib/opensearch/dsl/search/aggregations/avg.rb +51 -0
  10. data/lib/opensearch/dsl/search/aggregations/cardinality.rb +58 -0
  11. data/lib/opensearch/dsl/search/aggregations/children.rb +65 -0
  12. data/lib/opensearch/dsl/search/aggregations/composite.rb +68 -0
  13. data/lib/opensearch/dsl/search/aggregations/date_histogram.rb +66 -0
  14. data/lib/opensearch/dsl/search/aggregations/date_range.rb +60 -0
  15. data/lib/opensearch/dsl/search/aggregations/extended_stats.rb +50 -0
  16. data/lib/opensearch/dsl/search/aggregations/filter.rb +56 -0
  17. data/lib/opensearch/dsl/search/aggregations/filters.rb +61 -0
  18. data/lib/opensearch/dsl/search/aggregations/geo_bounds.rb +70 -0
  19. data/lib/opensearch/dsl/search/aggregations/geo_distance.rb +65 -0
  20. data/lib/opensearch/dsl/search/aggregations/geohash_grid.rb +61 -0
  21. data/lib/opensearch/dsl/search/aggregations/global.rb +54 -0
  22. data/lib/opensearch/dsl/search/aggregations/histogram.rb +61 -0
  23. data/lib/opensearch/dsl/search/aggregations/ip_range.rb +57 -0
  24. data/lib/opensearch/dsl/search/aggregations/max.rb +51 -0
  25. data/lib/opensearch/dsl/search/aggregations/min.rb +51 -0
  26. data/lib/opensearch/dsl/search/aggregations/missing.rb +61 -0
  27. data/lib/opensearch/dsl/search/aggregations/nested.rb +59 -0
  28. data/lib/opensearch/dsl/search/aggregations/percentile_ranks.rb +60 -0
  29. data/lib/opensearch/dsl/search/aggregations/percentiles.rb +59 -0
  30. data/lib/opensearch/dsl/search/aggregations/pipeline/avg_bucket.rb +59 -0
  31. data/lib/opensearch/dsl/search/aggregations/pipeline/bucket_script.rb +61 -0
  32. data/lib/opensearch/dsl/search/aggregations/pipeline/bucket_selector.rb +60 -0
  33. data/lib/opensearch/dsl/search/aggregations/pipeline/bucket_sort.rb +114 -0
  34. data/lib/opensearch/dsl/search/aggregations/pipeline/cumulative_sum.rb +58 -0
  35. data/lib/opensearch/dsl/search/aggregations/pipeline/derivative.rb +59 -0
  36. data/lib/opensearch/dsl/search/aggregations/pipeline/extended_stats_bucket.rb +59 -0
  37. data/lib/opensearch/dsl/search/aggregations/pipeline/max_bucket.rb +59 -0
  38. data/lib/opensearch/dsl/search/aggregations/pipeline/min_bucket.rb +59 -0
  39. data/lib/opensearch/dsl/search/aggregations/pipeline/moving_avg.rb +67 -0
  40. data/lib/opensearch/dsl/search/aggregations/pipeline/percentiles_bucket.rb +61 -0
  41. data/lib/opensearch/dsl/search/aggregations/pipeline/serial_diff.rb +61 -0
  42. data/lib/opensearch/dsl/search/aggregations/pipeline/stats_bucket.rb +59 -0
  43. data/lib/opensearch/dsl/search/aggregations/pipeline/sum_bucket.rb +59 -0
  44. data/lib/opensearch/dsl/search/aggregations/range.rb +79 -0
  45. data/lib/opensearch/dsl/search/aggregations/reverse_nested.rb +63 -0
  46. data/lib/opensearch/dsl/search/aggregations/scripted_metric.rb +65 -0
  47. data/lib/opensearch/dsl/search/aggregations/significant_terms.rb +71 -0
  48. data/lib/opensearch/dsl/search/aggregations/stats.rb +63 -0
  49. data/lib/opensearch/dsl/search/aggregations/sum.rb +51 -0
  50. data/lib/opensearch/dsl/search/aggregations/terms.rb +68 -0
  51. data/lib/opensearch/dsl/search/aggregations/top_hits.rb +61 -0
  52. data/lib/opensearch/dsl/search/aggregations/value_count.rb +51 -0
  53. data/lib/opensearch/dsl/search/base_aggregation_component.rb +90 -0
  54. data/lib/opensearch/dsl/search/base_component.rb +193 -0
  55. data/lib/opensearch/dsl/search/base_compound_filter_component.rb +123 -0
  56. data/lib/opensearch/dsl/search/filter.rb +81 -0
  57. data/lib/opensearch/dsl/search/filters/and.rb +71 -0
  58. data/lib/opensearch/dsl/search/filters/bool.rb +105 -0
  59. data/lib/opensearch/dsl/search/filters/exists.rb +58 -0
  60. data/lib/opensearch/dsl/search/filters/geo_bounding_box.rb +71 -0
  61. data/lib/opensearch/dsl/search/filters/geo_distance.rb +83 -0
  62. data/lib/opensearch/dsl/search/filters/geo_distance_range.rb +58 -0
  63. data/lib/opensearch/dsl/search/filters/geo_polygon.rb +67 -0
  64. data/lib/opensearch/dsl/search/filters/geo_shape.rb +61 -0
  65. data/lib/opensearch/dsl/search/filters/geohash_cell.rb +72 -0
  66. data/lib/opensearch/dsl/search/filters/has_child.rb +100 -0
  67. data/lib/opensearch/dsl/search/filters/has_parent.rb +99 -0
  68. data/lib/opensearch/dsl/search/filters/ids.rb +58 -0
  69. data/lib/opensearch/dsl/search/filters/indices.rb +103 -0
  70. data/lib/opensearch/dsl/search/filters/limit.rb +57 -0
  71. data/lib/opensearch/dsl/search/filters/match_all.rb +54 -0
  72. data/lib/opensearch/dsl/search/filters/missing.rb +60 -0
  73. data/lib/opensearch/dsl/search/filters/nested.rb +93 -0
  74. data/lib/opensearch/dsl/search/filters/not.rb +99 -0
  75. data/lib/opensearch/dsl/search/filters/or.rb +71 -0
  76. data/lib/opensearch/dsl/search/filters/prefix.rb +55 -0
  77. data/lib/opensearch/dsl/search/filters/query.rb +80 -0
  78. data/lib/opensearch/dsl/search/filters/range.rb +65 -0
  79. data/lib/opensearch/dsl/search/filters/regexp.rb +60 -0
  80. data/lib/opensearch/dsl/search/filters/script.rb +58 -0
  81. data/lib/opensearch/dsl/search/filters/term.rb +57 -0
  82. data/lib/opensearch/dsl/search/filters/terms.rb +58 -0
  83. data/lib/opensearch/dsl/search/filters/type.rb +60 -0
  84. data/lib/opensearch/dsl/search/highlight.rb +117 -0
  85. data/lib/opensearch/dsl/search/options.rb +81 -0
  86. data/lib/opensearch/dsl/search/queries/bool.rb +111 -0
  87. data/lib/opensearch/dsl/search/queries/boosting.rb +59 -0
  88. data/lib/opensearch/dsl/search/queries/common.rb +64 -0
  89. data/lib/opensearch/dsl/search/queries/constant_score.rb +92 -0
  90. data/lib/opensearch/dsl/search/queries/dis_max.rb +61 -0
  91. data/lib/opensearch/dsl/search/queries/exists.rb +69 -0
  92. data/lib/opensearch/dsl/search/queries/filtered.rb +103 -0
  93. data/lib/opensearch/dsl/search/queries/function_score.rb +128 -0
  94. data/lib/opensearch/dsl/search/queries/fuzzy.rb +71 -0
  95. data/lib/opensearch/dsl/search/queries/fuzzy_like_this.rb +63 -0
  96. data/lib/opensearch/dsl/search/queries/fuzzy_like_this_field.rb +62 -0
  97. data/lib/opensearch/dsl/search/queries/geo_shape.rb +56 -0
  98. data/lib/opensearch/dsl/search/queries/has_child.rb +84 -0
  99. data/lib/opensearch/dsl/search/queries/has_parent.rb +84 -0
  100. data/lib/opensearch/dsl/search/queries/ids.rb +54 -0
  101. data/lib/opensearch/dsl/search/queries/indices.rb +60 -0
  102. data/lib/opensearch/dsl/search/queries/match.rb +69 -0
  103. data/lib/opensearch/dsl/search/queries/match_all.rb +52 -0
  104. data/lib/opensearch/dsl/search/queries/match_phrase.rb +58 -0
  105. data/lib/opensearch/dsl/search/queries/match_phrase_prefix.rb +57 -0
  106. data/lib/opensearch/dsl/search/queries/more_like_this.rb +90 -0
  107. data/lib/opensearch/dsl/search/queries/multi_match.rb +71 -0
  108. data/lib/opensearch/dsl/search/queries/nested.rb +82 -0
  109. data/lib/opensearch/dsl/search/queries/prefix.rb +56 -0
  110. data/lib/opensearch/dsl/search/queries/query_string.rb +77 -0
  111. data/lib/opensearch/dsl/search/queries/range.rb +73 -0
  112. data/lib/opensearch/dsl/search/queries/regexp.rb +57 -0
  113. data/lib/opensearch/dsl/search/queries/simple_query_string.rb +66 -0
  114. data/lib/opensearch/dsl/search/queries/span_first.rb +54 -0
  115. data/lib/opensearch/dsl/search/queries/span_multi.rb +54 -0
  116. data/lib/opensearch/dsl/search/queries/span_near.rb +58 -0
  117. data/lib/opensearch/dsl/search/queries/span_not.rb +59 -0
  118. data/lib/opensearch/dsl/search/queries/span_or.rb +54 -0
  119. data/lib/opensearch/dsl/search/queries/span_term.rb +52 -0
  120. data/lib/opensearch/dsl/search/queries/template.rb +57 -0
  121. data/lib/opensearch/dsl/search/queries/term.rb +52 -0
  122. data/lib/opensearch/dsl/search/queries/terms.rb +53 -0
  123. data/lib/opensearch/dsl/search/queries/top_children.rb +84 -0
  124. data/lib/opensearch/dsl/search/queries/wildcard.rb +56 -0
  125. data/lib/opensearch/dsl/search/query.rb +80 -0
  126. data/lib/opensearch/dsl/search/sort.rb +84 -0
  127. data/lib/opensearch/dsl/search/suggest.rb +53 -0
  128. data/lib/opensearch/dsl/search.rb +288 -0
  129. data/lib/opensearch/dsl/utils.rb +51 -0
  130. data/lib/opensearch/dsl/version.rb +31 -0
  131. data/lib/opensearch/dsl.rb +72 -0
  132. data/lib/opensearch-dsl.rb +27 -0
  133. data/opensearch-dsl.gemspec +81 -0
  134. data/spec/opensearch/dsl/search/aggregations/avg_spec.rb +52 -0
  135. data/spec/opensearch/dsl/search/aggregations/cardinality_spec.rb +119 -0
  136. data/spec/opensearch/dsl/search/aggregations/children_spec.rb +75 -0
  137. data/spec/opensearch/dsl/search/aggregations/composite_spec.rb +108 -0
  138. data/spec/opensearch/dsl/search/aggregations/date_histogram_spec.rb +198 -0
  139. data/spec/opensearch/dsl/search/aggregations/date_range_spec.rb +98 -0
  140. data/spec/opensearch/dsl/search/aggregations/extended_stats_spec.rb +52 -0
  141. data/spec/opensearch/dsl/search/aggregations/filter_spec.rb +57 -0
  142. data/spec/opensearch/dsl/search/aggregations/filters_spec.rb +98 -0
  143. data/spec/opensearch/dsl/search/aggregations/geo_bounds_spec.rb +86 -0
  144. data/spec/opensearch/dsl/search/aggregations/geo_distance_spec.rb +122 -0
  145. data/spec/opensearch/dsl/search/aggregations/geo_grid_spec.rb +109 -0
  146. data/spec/opensearch/dsl/search/aggregations/global_spec.rb +71 -0
  147. data/spec/opensearch/dsl/search/aggregations/historgram_spec.rb +131 -0
  148. data/spec/opensearch/dsl/search/aggregations/ip_range_spec.rb +102 -0
  149. data/spec/opensearch/dsl/search/aggregations/max_spec.rb +52 -0
  150. data/spec/opensearch/dsl/search/aggregations/min_spec.rb +52 -0
  151. data/spec/opensearch/dsl/search/aggregations/missing_spec.rb +90 -0
  152. data/spec/opensearch/dsl/search/aggregations/nested_spec.rb +95 -0
  153. data/spec/opensearch/dsl/search/aggregations/percentile_ranks_spec.rb +135 -0
  154. data/spec/opensearch/dsl/search/aggregations/percentiles_spec.rb +134 -0
  155. data/spec/opensearch/dsl/search/aggregations/pipeline/avg_bucket_spec.rb +97 -0
  156. data/spec/opensearch/dsl/search/aggregations/pipeline/bucket_script_spec.rb +108 -0
  157. data/spec/opensearch/dsl/search/aggregations/pipeline/bucket_selector_spec.rb +97 -0
  158. data/spec/opensearch/dsl/search/aggregations/pipeline/bucket_sort_spec.rb +113 -0
  159. data/spec/opensearch/dsl/search/aggregations/pipeline/cumulative_sum_spec.rb +86 -0
  160. data/spec/opensearch/dsl/search/aggregations/pipeline/derivative_spec.rb +97 -0
  161. data/spec/opensearch/dsl/search/aggregations/pipeline/extended_stats_bucket_spec.rb +97 -0
  162. data/spec/opensearch/dsl/search/aggregations/pipeline/max_bucket_spec.rb +97 -0
  163. data/spec/opensearch/dsl/search/aggregations/pipeline/min_bucket_spec.rb +97 -0
  164. data/spec/opensearch/dsl/search/aggregations/pipeline/moving_avg_test_spec.rb +141 -0
  165. data/spec/opensearch/dsl/search/aggregations/pipeline/percentiles_bucket_spec.rb +108 -0
  166. data/spec/opensearch/dsl/search/aggregations/pipeline/serial_diff_spec.rb +108 -0
  167. data/spec/opensearch/dsl/search/aggregations/pipeline/stats_bucket_spec.rb +97 -0
  168. data/spec/opensearch/dsl/search/aggregations/pipeline/sum_bucket_spec.rb +97 -0
  169. data/spec/opensearch/dsl/search/aggregations/range_spec.rb +128 -0
  170. data/spec/opensearch/dsl/search/aggregations/reverse_nested_spec.rb +41 -0
  171. data/spec/opensearch/dsl/search/aggregations/scripted_metric_spec.rb +130 -0
  172. data/spec/opensearch/dsl/search/aggregations/significant_terms_spec.rb +185 -0
  173. data/spec/opensearch/dsl/search/aggregations/stats_spec.rb +65 -0
  174. data/spec/opensearch/dsl/search/aggregations/sum_spec.rb +52 -0
  175. data/spec/opensearch/dsl/search/aggregations/terms_spec.rb +174 -0
  176. data/spec/opensearch/dsl/search/aggregations/top_hits_spec.rb +97 -0
  177. data/spec/opensearch/dsl/search/aggregations/value_count_spec.rb +52 -0
  178. data/spec/opensearch/dsl/search/filters/and_spec.rb +83 -0
  179. data/spec/opensearch/dsl/search/filters/bool_spec.rb +208 -0
  180. data/spec/opensearch/dsl/search/filters/exists_spec.rb +75 -0
  181. data/spec/opensearch/dsl/search/filters/geo_bounding_box_spec.rb +153 -0
  182. data/spec/opensearch/dsl/search/filters/geo_distance_range_spec.rb +112 -0
  183. data/spec/opensearch/dsl/search/filters/geo_distance_spec.rb +135 -0
  184. data/spec/opensearch/dsl/search/filters/geo_polygon_spec.rb +75 -0
  185. data/spec/opensearch/dsl/search/filters/geo_shape_spec.rb +86 -0
  186. data/spec/opensearch/dsl/search/filters/geohash_cell_spec.rb +108 -0
  187. data/spec/opensearch/dsl/search/filters/has_child_spec.rb +148 -0
  188. data/spec/opensearch/dsl/search/filters/has_parent_spec.rb +137 -0
  189. data/spec/opensearch/dsl/search/filters/ids_spec.rb +87 -0
  190. data/spec/opensearch/dsl/search/filters/indices_spec.rb +118 -0
  191. data/spec/opensearch/dsl/search/filters/limit_spec.rb +75 -0
  192. data/spec/opensearch/dsl/search/filters/match_all_spec.rb +41 -0
  193. data/spec/opensearch/dsl/search/filters/missing_spec.rb +75 -0
  194. data/spec/opensearch/dsl/search/filters/nested_spec.rb +100 -0
  195. data/spec/opensearch/dsl/search/filters/not_spec.rb +68 -0
  196. data/spec/opensearch/dsl/search/filters/or_spec.rb +84 -0
  197. data/spec/opensearch/dsl/search/filters/prefix_spec.rb +55 -0
  198. data/spec/opensearch/dsl/search/filters/query_spec.rb +68 -0
  199. data/spec/opensearch/dsl/search/filters/range_spec.rb +120 -0
  200. data/spec/opensearch/dsl/search/filters/regexp_spec.rb +97 -0
  201. data/spec/opensearch/dsl/search/filters/script_spec.rb +86 -0
  202. data/spec/opensearch/dsl/search/filters/term_spec.rb +66 -0
  203. data/spec/opensearch/dsl/search/filters/terms_spec.rb +55 -0
  204. data/spec/opensearch/dsl/search/filters/type_spec.rb +75 -0
  205. data/spec/opensearch/dsl/search/queries/bool_spec.rb +276 -0
  206. data/spec/opensearch/dsl/search/queries/boosting_spec.rb +99 -0
  207. data/spec/opensearch/dsl/search/queries/common_spec.rb +141 -0
  208. data/spec/opensearch/dsl/search/queries/constant_score_spec.rb +99 -0
  209. data/spec/opensearch/dsl/search/queries/dis_max_spec.rb +97 -0
  210. data/spec/opensearch/dsl/search/queries/exists_spec.rb +75 -0
  211. data/spec/opensearch/dsl/search/queries/filtered_spec.rb +102 -0
  212. data/spec/opensearch/dsl/search/queries/function_score_spec.rb +173 -0
  213. data/spec/opensearch/dsl/search/queries/fuzzy_like_this_field_spec.rb +141 -0
  214. data/spec/opensearch/dsl/search/queries/fuzzy_like_this_spec.rb +143 -0
  215. data/spec/opensearch/dsl/search/queries/fuzzy_spec.rb +119 -0
  216. data/spec/opensearch/dsl/search/queries/geo_shape_spec.rb +86 -0
  217. data/spec/opensearch/dsl/search/queries/has_child_spec.rb +135 -0
  218. data/spec/opensearch/dsl/search/queries/has_parent_spec.rb +109 -0
  219. data/spec/opensearch/dsl/search/queries/ids_spec.rb +87 -0
  220. data/spec/opensearch/dsl/search/queries/indices_spec.rb +98 -0
  221. data/spec/opensearch/dsl/search/queries/match_all_spec.rb +75 -0
  222. data/spec/opensearch/dsl/search/queries/match_phrase_prefix_spec.rb +112 -0
  223. data/spec/opensearch/dsl/search/queries/match_phrase_spec.rb +123 -0
  224. data/spec/opensearch/dsl/search/queries/match_spec.rb +116 -0
  225. data/spec/opensearch/dsl/search/queries/more_like_this_spec.rb +96 -0
  226. data/spec/opensearch/dsl/search/queries/multi_match_spec.rb +83 -0
  227. data/spec/opensearch/dsl/search/queries/nested_spec.rb +107 -0
  228. data/spec/opensearch/dsl/search/queries/prefix_spec.rb +79 -0
  229. data/spec/opensearch/dsl/search/queries/query_string_spec.rb +98 -0
  230. data/spec/opensearch/dsl/search/queries/range_spec.rb +87 -0
  231. data/spec/opensearch/dsl/search/queries/regexp_spec.rb +91 -0
  232. data/spec/opensearch/dsl/search/queries/simple_query_string_spec.rb +83 -0
  233. data/spec/opensearch/dsl/search/queries/span_first_spec.rb +78 -0
  234. data/spec/opensearch/dsl/search/queries/span_multi_spec.rb +78 -0
  235. data/spec/opensearch/dsl/search/queries/span_near_spec.rb +81 -0
  236. data/spec/opensearch/dsl/search/queries/span_not_spec.rb +82 -0
  237. data/spec/opensearch/dsl/search/queries/span_or_spec.rb +78 -0
  238. data/spec/opensearch/dsl/search/queries/span_term_spec.rb +55 -0
  239. data/spec/opensearch/dsl/search/queries/template_spec.rb +93 -0
  240. data/spec/opensearch/dsl/search/queries/term_spec.rb +66 -0
  241. data/spec/opensearch/dsl/search/queries/terms_spec.rb +55 -0
  242. data/spec/opensearch/dsl/search/queries/top_children_spec.rb +102 -0
  243. data/spec/opensearch/dsl/search/queries/wildcard_spec.rb +90 -0
  244. data/spec/spec_helper.rb +33 -0
  245. data/test/integration/search_aggregation_children_test.rb +91 -0
  246. data/test/integration/search_aggregation_geo_test.rb +111 -0
  247. data/test/integration/search_aggregation_nested_test.rb +128 -0
  248. data/test/integration/search_aggregations_test.rb +287 -0
  249. data/test/integration/search_filters_test.rb +290 -0
  250. data/test/integration/search_options_test.rb +54 -0
  251. data/test/integration/search_query_test.rb +99 -0
  252. data/test/integration/search_size_from_test.rb +71 -0
  253. data/test/integration/search_sort_test.rb +58 -0
  254. data/test/integration/search_suggest_test.rb +103 -0
  255. data/test/integration/search_test.rb +82 -0
  256. data/test/test_helper.rb +95 -0
  257. data/test/unit/dsl_test.rb +44 -0
  258. data/test/unit/search_aggregation_test.rb +98 -0
  259. data/test/unit/search_base_aggregation_component_test.rb +67 -0
  260. data/test/unit/search_base_component_test.rb +212 -0
  261. data/test/unit/search_filter_test.rb +87 -0
  262. data/test/unit/search_highlight_test.rb +103 -0
  263. data/test/unit/search_options_test.rb +114 -0
  264. data/test/unit/search_query_test.rb +91 -0
  265. data/test/unit/search_size_from_test.rb +69 -0
  266. data/test/unit/search_sort_test.rb +91 -0
  267. data/test/unit/search_suggest_test.rb +46 -0
  268. data/test/unit/search_test.rb +270 -0
  269. data/test/unit/utils_test.rb +47 -0
  270. data.tar.gz.sig +3 -0
  271. metadata +654 -0
  272. metadata.gz.sig +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6345138436b27bcbb4ed3dc062220d4945ae079acb22544f5a16f0cc8d44a43f
4
+ data.tar.gz: 2c043715ba32ae26ef06ba43ffbdbdee4ffa03c3b39464c9ccbbb4e4c6dea298
5
+ SHA512:
6
+ metadata.gz: e1b52a6498cbf4daa244681e35fa6b5ea7bd910f097e5271c10e2eb70ba22e4baf6031c438675bd147e3ec785594c83e93728e583f9d4477e7dcc34eb25045a0
7
+ data.tar.gz: d2dcdd9b5633514157410a1691b8a838b6ebf9c592ea0bb67e948430526dc41d230ebe2918884a62a2d8fcdf04d88dea6d0c718601b32140f6c2a581e702f81c
checksums.yaml.gz.sig ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -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
+ source 'https://rubygems.org'
28
+
29
+ # Specify your gem's dependencies in opensearch-dsl.gemspec
30
+ gemspec
31
+
32
+ if File.exist? File.expand_path('../../opensearch/opensearch.gemspec', __FILE__)
33
+ gem 'opensearch-ruby', path: File.expand_path('../../opensearch', __FILE__), require: false
34
+ end
35
+
36
+ if File.exist? File.expand_path('../../opensearch-transport', __FILE__)
37
+ gem 'opensearch-transport', path: File.expand_path('../../opensearch-transport', __FILE__), require: true
38
+ end
39
+
40
+ if File.exist? File.expand_path('../../opensearch-api', __FILE__)
41
+ gem 'opensearch-api', path: File.expand_path('../../opensearch-api', __FILE__), require: false
42
+ end
43
+
44
+ group :development do
45
+ gem 'rspec'
46
+ if defined?(JRUBY_VERSION)
47
+ gem 'pry-nav'
48
+ else
49
+ gem 'pry-byebug'
50
+ end
51
+ end
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # OpenSearch::DSL
2
+
3
+ The `opensearch-dsl` library provides a Ruby API for
4
+ the `OpenSearch Query DSL`
5
+
6
+ The library is compatible with Ruby 1.9 or higher and OpenSearch 1.0.0 and higher.
7
+
8
+ ## Installation
9
+
10
+ Install the package from [Rubygems](https://rubygems.org):
11
+
12
+ gem install opensearch-dsl
13
+
14
+ To use an unreleased version, either add it to your `Gemfile` for [Bundler](http://gembundler.com):
15
+
16
+ gem 'opensearch-dsl', git: 'git://github.com/opensearch-project/opensearch-ruby.git'
17
+
18
+ or install it from a source code checkout:
19
+
20
+ git clone https://github.com/opensearch-project/opensearch-ruby
21
+ cd opensearch-ruby/opensearch-dsl
22
+ bundle install
23
+ rake install
24
+
25
+ ## Usage
26
+
27
+ The library is designed as a group of standalone Ruby modules, classes and DSL methods,
28
+ which provide an idiomatic way to build complex search definitions
29
+
30
+ Let's have a simple example using the declarative variant:
31
+
32
+ ```ruby
33
+ require 'opensearch'
34
+ require 'opensearch/dsl'
35
+ include OpenSearch::DSL
36
+
37
+ # If you want to use authentication credentials
38
+ client = OpenSearch::Client.new url: 'https://admin:admin@localhost:9200', log: true
39
+
40
+ # If you don't want to use authentication credentials
41
+ # client = OpenSearch::Client.new url: 'http://localhost:9200', log: true
42
+
43
+ index_name = 'my-dsl-index'
44
+ index_body = {
45
+ 'settings': {
46
+ 'index': {
47
+ 'number_of_shards': 4
48
+ }
49
+ }
50
+ }
51
+ response = client.indices.create(
52
+ index: index_name,
53
+ body: index_body
54
+ )
55
+
56
+ puts 'Creating index:'
57
+ puts response
58
+
59
+ # Add a document to the index.
60
+ document = {
61
+ 'title': 'ruby',
62
+ 'description': 'beta',
63
+ 'category': 'search'
64
+ }
65
+ id = '1'
66
+
67
+ response = client.index(
68
+ index: index_name,
69
+ body: document,
70
+ id: id,
71
+ refresh: true
72
+ )
73
+
74
+ puts 'Adding document:'
75
+ puts response
76
+
77
+ response = client.search index: index_name, body: search {
78
+ query do
79
+ bool do
80
+ filter do
81
+ term category: "search"
82
+ end
83
+ must do
84
+ match title: "ruby"
85
+ end
86
+ end
87
+ end
88
+ }.to_hash
89
+
90
+ puts 'Search results:'
91
+ puts response
92
+
93
+
94
+ # Delete the document.
95
+ response = client.delete(
96
+ index: index_name,
97
+ id: id
98
+ )
99
+
100
+ puts 'Deleting document:'
101
+ puts response
102
+
103
+ # Delete the index.
104
+ response = client.indices.delete(
105
+ index: index_name
106
+ )
107
+
108
+ puts 'Deleting index:'
109
+ puts response
110
+
111
+ ```
112
+
113
+ ## Features Overview
114
+
115
+ The library allows to programatically build complex search definitions for OpenSearch in Ruby,
116
+ which are translated to Hashes, and ultimately, JSON, the language of OpenSearch.
117
+
118
+ All OpenSearch DSL features are supported, namely:
119
+
120
+ * Queries and Filter context
121
+ * Aggregations
122
+ * Suggestions
123
+ * Sorting
124
+ * Pagination
125
+ * Options
126
+
127
+ ## Development
128
+
129
+ To work on the code, clone the repository and install the dependencies:
130
+
131
+ ```
132
+ git clone https://github.com/opensearch-project/opensearch-ruby
133
+ cd opensearch-ruby/opensearch-dsl/
134
+ bundle install
135
+ ```
136
+
137
+ Use the Rake tasks to run the test suites:
138
+
139
+ ```
140
+ bundle exec rake test:unit
141
+ bundle exec rake test:integration
142
+ ```
143
+
144
+ To launch a separate OpenSearch server for integration tests,
145
+ see instructions in the main [README](../README.md#development).
146
+
147
+ ## License
148
+
149
+ This software is licensed under the [Apache 2 license](./LICENSE).
data/Rakefile ADDED
@@ -0,0 +1,234 @@
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 "bundler/gem_tasks"
28
+
29
+ task(:default) { system "rake --tasks" }
30
+ task :test => 'test:unit'
31
+
32
+ # ----- Test tasks ------------------------------------------------------------
33
+
34
+ require 'rake/testtask'
35
+ require 'rspec/core/rake_task'
36
+
37
+ namespace :test do
38
+
39
+ desc "Wait for OpenSearch to be in a green state"
40
+ task :wait_for_green do
41
+ sh '../scripts/wait-cluster.sh'
42
+ end
43
+
44
+ RSpec::Core::RakeTask.new(:spec)
45
+
46
+ Rake::TestTask.new(:unit) do |test|
47
+ test.libs << 'lib' << 'test'
48
+ test.test_files = FileList["test/unit/**/*_test.rb"]
49
+ test.deps = [ :spec ]
50
+ test.verbose = false
51
+ test.warning = false
52
+ end
53
+
54
+ Rake::TestTask.new(:integration) do |test|
55
+ test.deps = [ :wait_for_green ]
56
+ test.libs << 'lib' << 'test'
57
+ test.test_files = FileList["test/integration/**/*_test.rb"]
58
+ test.verbose = false
59
+ test.warning = false
60
+ end
61
+
62
+ desc "Run unit and integration tests"
63
+ task :all do
64
+ Rake::Task['test:unit'].invoke
65
+ Rake::Task['test:integration'].invoke
66
+ end
67
+
68
+ end
69
+
70
+ # ----- Documentation tasks ---------------------------------------------------
71
+
72
+ require 'yard'
73
+ YARD::Rake::YardocTask.new(:doc) do |t|
74
+ t.options = %w| --embed-mixins --markup=markdown |
75
+ end
76
+
77
+ # ----- Code analysis tasks ---------------------------------------------------
78
+
79
+ require 'cane/rake_task'
80
+ Cane::RakeTask.new(:quality) do |cane|
81
+ cane.abc_max = 15
82
+ cane.no_style = true
83
+ end
84
+
85
+ # ----- Generating the source code --------------------------------------------
86
+
87
+ require 'net/http'
88
+ require 'json'
89
+ require 'coderay'
90
+
91
+ namespace :generate do
92
+ desc <<-DESC.gsub(/^ /, '')
93
+ Generate Ruby source and tests for query/filter/aggregation
94
+
95
+ Pass the type of the component, the name, and any option methods as Rake task arguments.
96
+
97
+ Example:
98
+
99
+ $ rake generate:source[query,boosting]
100
+ Source: /.../opensearch-ruby/opensearch-dsl/lib/opensearch/dsl/search/queries/boosting.rb
101
+ ...
102
+ Test: /.../opensearch-ruby/opensearch-dsl/test/unit/queries/boosting_test.rb
103
+ ...
104
+
105
+ $ rake generate:source[query,common,query/cutoff_frequency/low_freq_operator/...]
106
+ Source: /.../opensearch-ruby/opensearch-dsl/lib/opensearch/dsl/search/queries/common.rb
107
+ ...
108
+ Test: /.../opensearch-ruby/opensearch-dsl/test/unit/queries/common_test.rb
109
+ ...
110
+
111
+ DESC
112
+ task :source, [:type, :name, :option_methods] do |task, options|
113
+ begin
114
+ query = URI.escape("#{options[:name]} #{options[:type]}")
115
+ response = Net::HTTP.get('search.opensearch.org', "/search/?q=#{query}")
116
+ hits = JSON.load(response)['hits']['hits']
117
+
118
+ if hit = hits.first
119
+ doc_url = ("http://opensearch.org" + hit['fields']['url']).gsub(/#.+$/, '') if hit['_score'] > 0.2
120
+ end
121
+ rescue Exception => e
122
+ puts "[!] ERROR: #{e.inspect}"
123
+ end unless ENV['NOCRAWL']
124
+
125
+ case options[:type]
126
+ when /query/
127
+ module_name = 'Queries'
128
+ path_name = 'queries'
129
+ include_module = 'BaseComponent'
130
+ when /filter/
131
+ module_name = 'Filters'
132
+ path_name = 'filters'
133
+ include_module = 'BaseComponent'
134
+ when /agg/
135
+ module_name = 'Aggregations'
136
+ path_name = 'aggregations'
137
+ include_module = 'BaseAggregationComponent'
138
+ else raise ArgumentError, "Unknown DSL type [#{options[:type]}]"
139
+ end
140
+
141
+ name = options[:name].downcase
142
+
143
+ class_name = options[:name].split('_').map(&:capitalize).join
144
+
145
+ option_methods = options[:option_methods].to_s.split('/').reduce('') do |sum, item|
146
+ sum << " "
147
+ sum << "option_method :#{item}"
148
+ sum << "\n" unless item == options[:option_methods].to_s.split('/').last
149
+ sum
150
+ end
151
+
152
+ option_methods = "\n\n#{option_methods}" unless option_methods.empty?
153
+
154
+ source = <<-RUBY.gsub(/^ /, '')
155
+ module OpenSearch
156
+ module DSL
157
+ module Search
158
+ module #{module_name}
159
+
160
+ # #{class_name} #{options[:type]}
161
+ #
162
+ # @example
163
+ #
164
+ # @see #{doc_url}
165
+ #
166
+ class #{class_name}
167
+ include #{include_module}#{option_methods}
168
+ end
169
+
170
+ end
171
+ end
172
+ end
173
+ end
174
+ RUBY
175
+
176
+ if options[:option_methods].to_s.empty?
177
+ test_option_methods = ''
178
+ else
179
+ setup = "\n" + options[:option_methods].to_s.split('/').reduce('') do |sum,item|
180
+ sum << " subject.#{item} 'bar'\n"; sum
181
+ end
182
+ asserts = "\n assert_equal %w[ #{options[:option_methods].to_s.split('/').sort.join(' ')} ],\n subject.to_hash[:#{name}][:foo].keys.map(&:to_s).sort"
183
+ asserts << "\n assert_equal 'bar', subject.to_hash[:#{name}][:foo][:#{options[:option_methods].to_s.split('/').first}]"
184
+
185
+ test_option_methods = <<-RUBY.gsub(/^ /, '')
186
+
187
+ should "have option methods" do
188
+ subject = #{class_name}.new :foo
189
+ #{setup}#{asserts}
190
+ end
191
+
192
+ should "take a block" do
193
+ subject = #{class_name}.new :foo do
194
+ #{options[:option_methods].to_s.split('/').first} 'bar'
195
+ end
196
+ assert_equal({#{name}: { foo: { #{options[:option_methods].to_s.split('/').first}: 'bar' } }}, subject.to_hash)
197
+ end
198
+ RUBY
199
+ end
200
+
201
+ test = <<-RUBY.gsub(/^ /, '')
202
+ require 'test_helper'
203
+
204
+ module OpenSearch
205
+ module Test
206
+ module #{module_name}
207
+ class #{class_name}Test < ::OpenSearch::Test::UnitTestCase
208
+ include OpenSearch::DSL::Search::#{module_name}
209
+
210
+ context "#{class_name} #{options[:type]}" do
211
+ subject { #{class_name}.new }
212
+
213
+ should "be converted to a Hash" do
214
+ assert_equal({ #{name}: {} }, subject.to_hash)
215
+ end
216
+ #{test_option_methods.empty? ? '' : test_option_methods.split("\n").map { |l| ' ' + l }.join("\n")}
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
222
+ RUBY
223
+
224
+ source_full_path = File.expand_path("../lib/opensearch/dsl/search/#{path_name}/#{name}.rb", __FILE__)
225
+ test_full_path = File.expand_path("../test/unit/#{path_name}/#{name}_test.rb", __FILE__)
226
+
227
+ puts '-'*80, "Source: #{source_full_path}", '-'*80, "\n", CodeRay.scan(source, :ruby).terminal, "\n\n"
228
+ puts '-'*80, "Test: #{test_full_path}", '-'*80, "\n", CodeRay.scan(test, :ruby).terminal, "\n"
229
+
230
+ File.open(source_full_path, 'w') { |file| file << source }
231
+
232
+ File.open(test_full_path, 'w') { |file| file << test }
233
+ end
234
+ end