opensearch-api 1.0.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 +48 -0
- data/LICENSE +202 -0
- data/README.md +194 -0
- data/Rakefile +131 -0
- data/lib/opensearch/api/actions/abort_benchmark.rb +49 -0
- data/lib/opensearch/api/actions/benchmark.rb +89 -0
- data/lib/opensearch/api/actions/bulk.rb +97 -0
- data/lib/opensearch/api/actions/cat/aliases.rb +79 -0
- data/lib/opensearch/api/actions/cat/allocation.rb +81 -0
- data/lib/opensearch/api/actions/cat/count.rb +75 -0
- data/lib/opensearch/api/actions/cat/fielddata.rb +77 -0
- data/lib/opensearch/api/actions/cat/health.rb +72 -0
- data/lib/opensearch/api/actions/cat/help.rb +61 -0
- data/lib/opensearch/api/actions/cat/indices.rb +91 -0
- data/lib/opensearch/api/actions/cat/master.rb +71 -0
- data/lib/opensearch/api/actions/cat/nodeattrs.rb +71 -0
- data/lib/opensearch/api/actions/cat/nodes.rb +80 -0
- data/lib/opensearch/api/actions/cat/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/cat/pending_tasks.rb +74 -0
- data/lib/opensearch/api/actions/cat/plugins.rb +73 -0
- data/lib/opensearch/api/actions/cat/recovery.rb +84 -0
- data/lib/opensearch/api/actions/cat/repositories.rb +72 -0
- data/lib/opensearch/api/actions/cat/segments.rb +76 -0
- data/lib/opensearch/api/actions/cat/shards.rb +83 -0
- data/lib/opensearch/api/actions/cat/snapshots.rb +80 -0
- data/lib/opensearch/api/actions/cat/tasks.rb +77 -0
- data/lib/opensearch/api/actions/cat/templates.rb +78 -0
- data/lib/opensearch/api/actions/cat/thread_pool.rb +82 -0
- data/lib/opensearch/api/actions/clear_scroll.rb +62 -0
- data/lib/opensearch/api/actions/close_point_in_time.rb +50 -0
- data/lib/opensearch/api/actions/cluster/allocation_explain.rb +67 -0
- data/lib/opensearch/api/actions/cluster/delete_component_template.rb +66 -0
- data/lib/opensearch/api/actions/cluster/delete_voting_config_exclusions.rb +59 -0
- data/lib/opensearch/api/actions/cluster/exists_component_template.rb +68 -0
- data/lib/opensearch/api/actions/cluster/get_component_template.rb +68 -0
- data/lib/opensearch/api/actions/cluster/get_settings.rb +65 -0
- data/lib/opensearch/api/actions/cluster/health.rb +86 -0
- data/lib/opensearch/api/actions/cluster/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/cluster/pending_tasks.rb +62 -0
- data/lib/opensearch/api/actions/cluster/post_voting_config_exclusions.rb +63 -0
- data/lib/opensearch/api/actions/cluster/put_component_template.rb +70 -0
- data/lib/opensearch/api/actions/cluster/put_settings.rb +66 -0
- data/lib/opensearch/api/actions/cluster/remote_info.rb +51 -0
- data/lib/opensearch/api/actions/cluster/reroute.rb +70 -0
- data/lib/opensearch/api/actions/cluster/state.rb +85 -0
- data/lib/opensearch/api/actions/cluster/stats.rb +68 -0
- data/lib/opensearch/api/actions/count.rb +101 -0
- data/lib/opensearch/api/actions/create.rb +61 -0
- data/lib/opensearch/api/actions/dangling_indices/delete_dangling_index.rb +68 -0
- data/lib/opensearch/api/actions/dangling_indices/import_dangling_index.rb +67 -0
- data/lib/opensearch/api/actions/dangling_indices/list_dangling_indices.rb +51 -0
- data/lib/opensearch/api/actions/dangling_indices/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/delete.rb +96 -0
- data/lib/opensearch/api/actions/delete_by_query.rb +140 -0
- data/lib/opensearch/api/actions/delete_by_query_rethrottle.rb +62 -0
- data/lib/opensearch/api/actions/delete_by_rethrottle.rb +55 -0
- data/lib/opensearch/api/actions/delete_script.rb +64 -0
- data/lib/opensearch/api/actions/exists.rb +101 -0
- data/lib/opensearch/api/actions/exists_source.rb +96 -0
- data/lib/opensearch/api/actions/explain.rb +106 -0
- data/lib/opensearch/api/actions/features/get_features.rb +59 -0
- data/lib/opensearch/api/actions/features/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/features/reset_features.rb +55 -0
- data/lib/opensearch/api/actions/field_caps.rb +78 -0
- data/lib/opensearch/api/actions/get.rb +100 -0
- data/lib/opensearch/api/actions/get_script.rb +62 -0
- data/lib/opensearch/api/actions/get_script_context.rb +53 -0
- data/lib/opensearch/api/actions/get_script_languages.rb +53 -0
- data/lib/opensearch/api/actions/get_source.rb +94 -0
- data/lib/opensearch/api/actions/index.rb +103 -0
- data/lib/opensearch/api/actions/indices/add_block.rb +76 -0
- data/lib/opensearch/api/actions/indices/analyze.rb +71 -0
- data/lib/opensearch/api/actions/indices/clear_cache.rb +79 -0
- data/lib/opensearch/api/actions/indices/clone.rb +73 -0
- data/lib/opensearch/api/actions/indices/close.rb +74 -0
- data/lib/opensearch/api/actions/indices/create.rb +71 -0
- data/lib/opensearch/api/actions/indices/delete.rb +76 -0
- data/lib/opensearch/api/actions/indices/delete_alias.rb +72 -0
- data/lib/opensearch/api/actions/indices/delete_index_template.rb +66 -0
- data/lib/opensearch/api/actions/indices/delete_template.rb +70 -0
- data/lib/opensearch/api/actions/indices/disk_usage.rb +76 -0
- data/lib/opensearch/api/actions/indices/exists.rb +79 -0
- data/lib/opensearch/api/actions/indices/exists_alias.rb +82 -0
- data/lib/opensearch/api/actions/indices/exists_index_template.rb +70 -0
- data/lib/opensearch/api/actions/indices/exists_template.rb +73 -0
- data/lib/opensearch/api/actions/indices/exists_type.rb +79 -0
- data/lib/opensearch/api/actions/indices/field_usage_stats.rb +74 -0
- data/lib/opensearch/api/actions/indices/flush.rb +74 -0
- data/lib/opensearch/api/actions/indices/flush_synced.rb +79 -0
- data/lib/opensearch/api/actions/indices/forcemerge.rb +76 -0
- data/lib/opensearch/api/actions/indices/get.rb +78 -0
- data/lib/opensearch/api/actions/indices/get_alias.rb +79 -0
- data/lib/opensearch/api/actions/indices/get_field_mapping.rb +92 -0
- data/lib/opensearch/api/actions/indices/get_index_template.rb +70 -0
- data/lib/opensearch/api/actions/indices/get_mapping.rb +88 -0
- data/lib/opensearch/api/actions/indices/get_settings.rb +85 -0
- data/lib/opensearch/api/actions/indices/get_template.rb +72 -0
- data/lib/opensearch/api/actions/indices/get_upgrade.rb +75 -0
- data/lib/opensearch/api/actions/indices/open.rb +74 -0
- data/lib/opensearch/api/actions/indices/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/indices/put_alias.rb +73 -0
- data/lib/opensearch/api/actions/indices/put_index_template.rb +70 -0
- data/lib/opensearch/api/actions/indices/put_mapping.rb +91 -0
- data/lib/opensearch/api/actions/indices/put_settings.rb +81 -0
- data/lib/opensearch/api/actions/indices/put_template.rb +72 -0
- data/lib/opensearch/api/actions/indices/recovery.rb +68 -0
- data/lib/opensearch/api/actions/indices/refresh.rb +70 -0
- data/lib/opensearch/api/actions/indices/resolve_index.rb +68 -0
- data/lib/opensearch/api/actions/indices/rollover.rb +81 -0
- data/lib/opensearch/api/actions/indices/segments.rb +72 -0
- data/lib/opensearch/api/actions/indices/shard_stores.rb +72 -0
- data/lib/opensearch/api/actions/indices/shrink.rb +75 -0
- data/lib/opensearch/api/actions/indices/simulate_index_template.rb +69 -0
- data/lib/opensearch/api/actions/indices/simulate_template.rb +71 -0
- data/lib/opensearch/api/actions/indices/split.rb +75 -0
- data/lib/opensearch/api/actions/indices/stats.rb +100 -0
- data/lib/opensearch/api/actions/indices/update_aliases.rb +64 -0
- data/lib/opensearch/api/actions/indices/upgrade.rb +79 -0
- data/lib/opensearch/api/actions/indices/validate_query.rb +104 -0
- data/lib/opensearch/api/actions/info.rb +49 -0
- data/lib/opensearch/api/actions/ingest/delete_pipeline.rb +66 -0
- data/lib/opensearch/api/actions/ingest/geo_ip_stats.rb +51 -0
- data/lib/opensearch/api/actions/ingest/get_pipeline.rb +68 -0
- data/lib/opensearch/api/actions/ingest/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/ingest/processor_grok.rb +51 -0
- data/lib/opensearch/api/actions/ingest/put_pipeline.rb +68 -0
- data/lib/opensearch/api/actions/ingest/simulate.rb +69 -0
- data/lib/opensearch/api/actions/mget.rb +91 -0
- data/lib/opensearch/api/actions/msearch.rb +112 -0
- data/lib/opensearch/api/actions/msearch_template.rb +96 -0
- data/lib/opensearch/api/actions/mtermvectors.rb +107 -0
- data/lib/opensearch/api/actions/nodes/hot_threads.rb +81 -0
- data/lib/opensearch/api/actions/nodes/info.rb +75 -0
- data/lib/opensearch/api/actions/nodes/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/nodes/reload_secure_settings.rb +67 -0
- data/lib/opensearch/api/actions/nodes/shutdown.rb +65 -0
- data/lib/opensearch/api/actions/nodes/stats.rb +96 -0
- data/lib/opensearch/api/actions/nodes/usage.rb +73 -0
- data/lib/opensearch/api/actions/open_point_in_time.rb +72 -0
- data/lib/opensearch/api/actions/params_registry.rb +67 -0
- data/lib/opensearch/api/actions/ping.rb +57 -0
- data/lib/opensearch/api/actions/put_script.rb +74 -0
- data/lib/opensearch/api/actions/rank_eval.rb +77 -0
- data/lib/opensearch/api/actions/reindex.rb +76 -0
- data/lib/opensearch/api/actions/reindex_rethrottle.rb +62 -0
- data/lib/opensearch/api/actions/remote/info.rb +45 -0
- data/lib/opensearch/api/actions/render_search_template.rb +62 -0
- data/lib/opensearch/api/actions/scripts_painless_execute.rb +59 -0
- data/lib/opensearch/api/actions/scroll.rb +78 -0
- data/lib/opensearch/api/actions/search.rb +165 -0
- data/lib/opensearch/api/actions/search_shards.rb +74 -0
- data/lib/opensearch/api/actions/search_template.rb +101 -0
- data/lib/opensearch/api/actions/shutdown/delete_node.rb +60 -0
- data/lib/opensearch/api/actions/shutdown/get_node.rb +62 -0
- data/lib/opensearch/api/actions/shutdown/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/shutdown/put_node.rb +62 -0
- data/lib/opensearch/api/actions/snapshot/cleanup_repository.rb +66 -0
- data/lib/opensearch/api/actions/snapshot/clone.rb +74 -0
- data/lib/opensearch/api/actions/snapshot/create.rb +71 -0
- data/lib/opensearch/api/actions/snapshot/create_repository.rb +70 -0
- data/lib/opensearch/api/actions/snapshot/delete.rb +72 -0
- data/lib/opensearch/api/actions/snapshot/delete_repository.rb +70 -0
- data/lib/opensearch/api/actions/snapshot/get.rb +80 -0
- data/lib/opensearch/api/actions/snapshot/get_features.rb +59 -0
- data/lib/opensearch/api/actions/snapshot/get_repository.rb +72 -0
- data/lib/opensearch/api/actions/snapshot/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/snapshot/repository_analyze.rb +84 -0
- data/lib/opensearch/api/actions/snapshot/restore.rb +71 -0
- data/lib/opensearch/api/actions/snapshot/status.rb +77 -0
- data/lib/opensearch/api/actions/snapshot/verify_repository.rb +66 -0
- data/lib/opensearch/api/actions/tasks/cancel.rb +76 -0
- data/lib/opensearch/api/actions/tasks/get.rb +68 -0
- data/lib/opensearch/api/actions/tasks/list.rb +75 -0
- data/lib/opensearch/api/actions/tasks/params_registry.rb +69 -0
- data/lib/opensearch/api/actions/termvectors.rb +115 -0
- data/lib/opensearch/api/actions/update.rb +106 -0
- data/lib/opensearch/api/actions/update_by_query.rb +144 -0
- data/lib/opensearch/api/actions/update_by_query_rethrottle.rb +62 -0
- data/lib/opensearch/api/namespace/cat.rb +45 -0
- data/lib/opensearch/api/namespace/cluster.rb +46 -0
- data/lib/opensearch/api/namespace/common.rb +53 -0
- data/lib/opensearch/api/namespace/dangling_indices.rb +44 -0
- data/lib/opensearch/api/namespace/features.rb +45 -0
- data/lib/opensearch/api/namespace/indices.rb +46 -0
- data/lib/opensearch/api/namespace/ingest.rb +46 -0
- data/lib/opensearch/api/namespace/nodes.rb +46 -0
- data/lib/opensearch/api/namespace/remote.rb +46 -0
- data/lib/opensearch/api/namespace/security.rb +45 -0
- data/lib/opensearch/api/namespace/shutdown.rb +46 -0
- data/lib/opensearch/api/namespace/snapshot.rb +46 -0
- data/lib/opensearch/api/namespace/tasks.rb +46 -0
- data/lib/opensearch/api/utils.rb +297 -0
- data/lib/opensearch/api/version.rb +31 -0
- data/lib/opensearch/api.rb +101 -0
- data/lib/opensearch-api.rb +27 -0
- data/opensearch-api.gemspec +92 -0
- data/spec/opensearch/api/actions/abort_benchmark_spec.rb +43 -0
- data/spec/opensearch/api/actions/benchmark_spec.rb +43 -0
- data/spec/opensearch/api/actions/bulk_spec.rb +148 -0
- data/spec/opensearch/api/actions/cat/aliases_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/allocation_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/count_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/fielddata_spec.rb +61 -0
- data/spec/opensearch/api/actions/cat/health_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/help_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/indices_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/master_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/nodeattrs_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/nodes_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/pending_tasks_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/plugins_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/recovery_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/repositories_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/segments_spec.rb +58 -0
- data/spec/opensearch/api/actions/cat/shards_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/snapshot_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/tasks_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/templates_spec.rb +44 -0
- data/spec/opensearch/api/actions/cat/thread_pool_spec.rb +44 -0
- data/spec/opensearch/api/actions/clear_scroll_spec.rb +61 -0
- data/spec/opensearch/api/actions/close_point_in_time_spec.rb +43 -0
- data/spec/opensearch/api/actions/cluster/allocation_explain_spec.rb +44 -0
- data/spec/opensearch/api/actions/cluster/get_settings_spec.rb +44 -0
- data/spec/opensearch/api/actions/cluster/health_spec.rb +78 -0
- data/spec/opensearch/api/actions/cluster/pending_tasks_spec.rb +44 -0
- data/spec/opensearch/api/actions/cluster/put_settings_spec.rb +44 -0
- data/spec/opensearch/api/actions/cluster/remote_info_spec.rb +44 -0
- data/spec/opensearch/api/actions/cluster/reroute_spec.rb +61 -0
- data/spec/opensearch/api/actions/cluster/state_spec.rb +61 -0
- data/spec/opensearch/api/actions/cluster/stats_spec.rb +44 -0
- data/spec/opensearch/api/actions/count_spec.rb +78 -0
- data/spec/opensearch/api/actions/create_document_spec.rb +95 -0
- data/spec/opensearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb +57 -0
- data/spec/opensearch/api/actions/dangling_indices/import_dangling_indices_spec.rb +57 -0
- data/spec/opensearch/api/actions/dangling_indices/list_dangling_indices_spec.rb +45 -0
- data/spec/opensearch/api/actions/delete_by_query_spec.rb +89 -0
- data/spec/opensearch/api/actions/delete_document_spec.rb +121 -0
- data/spec/opensearch/api/actions/delete_script_spec.rb +46 -0
- data/spec/opensearch/api/actions/exists_document_spec.rb +136 -0
- data/spec/opensearch/api/actions/explain_document_spec.rb +108 -0
- data/spec/opensearch/api/actions/features/get_features_spec.rb +43 -0
- data/spec/opensearch/api/actions/features/reset_features_spec.rb +43 -0
- data/spec/opensearch/api/actions/field_caps_spec.rb +44 -0
- data/spec/opensearch/api/actions/get_document_source_spec.rb +110 -0
- data/spec/opensearch/api/actions/get_document_spec.rb +133 -0
- data/spec/opensearch/api/actions/get_script_spec.rb +59 -0
- data/spec/opensearch/api/actions/hashie_spec.rb +98 -0
- data/spec/opensearch/api/actions/index_document_spec.rb +146 -0
- data/spec/opensearch/api/actions/indices/add_block_spec.rb +72 -0
- data/spec/opensearch/api/actions/indices/analyze_spec.rb +77 -0
- data/spec/opensearch/api/actions/indices/clear_cache_spec.rb +89 -0
- data/spec/opensearch/api/actions/indices/clone_spec.rb +131 -0
- data/spec/opensearch/api/actions/indices/close_spec.rb +94 -0
- data/spec/opensearch/api/actions/indices/create_spec.rb +94 -0
- data/spec/opensearch/api/actions/indices/delete_alias_spec.rb +92 -0
- data/spec/opensearch/api/actions/indices/delete_spec.rb +117 -0
- data/spec/opensearch/api/actions/indices/delete_template_spec.rb +95 -0
- data/spec/opensearch/api/actions/indices/disk_usage_spec.rb +57 -0
- data/spec/opensearch/api/actions/indices/exists_alias_spec.rb +117 -0
- data/spec/opensearch/api/actions/indices/exists_spec.rb +117 -0
- data/spec/opensearch/api/actions/indices/exists_template_spec.rb +102 -0
- data/spec/opensearch/api/actions/indices/exists_type_spec.rb +117 -0
- data/spec/opensearch/api/actions/indices/field_usage_stats_spec.rb +55 -0
- data/spec/opensearch/api/actions/indices/flush_spec.rb +100 -0
- data/spec/opensearch/api/actions/indices/flush_synced_spec.rb +99 -0
- data/spec/opensearch/api/actions/indices/forcemerge_spec.rb +44 -0
- data/spec/opensearch/api/actions/indices/get_alias_spec.rb +70 -0
- data/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb +70 -0
- data/spec/opensearch/api/actions/indices/get_mapping_spec.rb +92 -0
- data/spec/opensearch/api/actions/indices/get_settings_spec.rb +81 -0
- data/spec/opensearch/api/actions/indices/get_spec.rb +63 -0
- data/spec/opensearch/api/actions/indices/open_spec.rb +74 -0
- data/spec/opensearch/api/actions/indices/put_alias_spec.rb +98 -0
- data/spec/opensearch/api/actions/indices/put_mapping_spec.rb +111 -0
- data/spec/opensearch/api/actions/indices/put_settings_spec.rb +117 -0
- data/spec/opensearch/api/actions/indices/put_template_spec.rb +116 -0
- data/spec/opensearch/api/actions/indices/recovery_spec.rb +44 -0
- data/spec/opensearch/api/actions/indices/refresh_spec.rb +100 -0
- data/spec/opensearch/api/actions/indices/rollover_spec.rb +67 -0
- data/spec/opensearch/api/actions/indices/segments_spec.rb +100 -0
- data/spec/opensearch/api/actions/indices/shard_stores_spec.rb +44 -0
- data/spec/opensearch/api/actions/indices/shrink_spec.rb +51 -0
- data/spec/opensearch/api/actions/indices/split_spec.rb +44 -0
- data/spec/opensearch/api/actions/indices/stats_spec.rb +133 -0
- data/spec/opensearch/api/actions/indices/update_aliases_spec.rb +76 -0
- data/spec/opensearch/api/actions/indices/upgrade_spec.rb +44 -0
- data/spec/opensearch/api/actions/indices/validate_query_spec.rb +131 -0
- data/spec/opensearch/api/actions/info_spec.rb +44 -0
- data/spec/opensearch/api/actions/ingest/delete_pipeline_spec.rb +69 -0
- data/spec/opensearch/api/actions/ingest/geo_ip_stats_spec.rb +43 -0
- data/spec/opensearch/api/actions/ingest/get_pipeline_spec.rb +59 -0
- data/spec/opensearch/api/actions/ingest/put_pipeline_spec.rb +69 -0
- data/spec/opensearch/api/actions/ingest/simulate_spec.rb +58 -0
- data/spec/opensearch/api/actions/json_builders_spec.rb +93 -0
- data/spec/opensearch/api/actions/mget_spec.rb +111 -0
- data/spec/opensearch/api/actions/msearch_spec.rb +160 -0
- data/spec/opensearch/api/actions/msearch_template_spec.rb +102 -0
- data/spec/opensearch/api/actions/mtermvectors_spec.rb +55 -0
- data/spec/opensearch/api/actions/nodes/hot_threads_spec.rb +70 -0
- data/spec/opensearch/api/actions/nodes/info_spec.rb +111 -0
- data/spec/opensearch/api/actions/nodes/reload_secure_settings_spec.rb +93 -0
- data/spec/opensearch/api/actions/nodes/shutdown_spec.rb +85 -0
- data/spec/opensearch/api/actions/nodes/stats_spec.rb +85 -0
- data/spec/opensearch/api/actions/open_point_in_time_spec.rb +53 -0
- data/spec/opensearch/api/actions/ping_spec.rb +85 -0
- data/spec/opensearch/api/actions/put_script_spec.rb +65 -0
- data/spec/opensearch/api/actions/reindex_spec.rb +44 -0
- data/spec/opensearch/api/actions/remote/info_spec.rb +44 -0
- data/spec/opensearch/api/actions/render_search_template_spec.rb +61 -0
- data/spec/opensearch/api/actions/scroll_spec.rb +61 -0
- data/spec/opensearch/api/actions/search_shards_spec.rb +44 -0
- data/spec/opensearch/api/actions/search_spec.rb +143 -0
- data/spec/opensearch/api/actions/search_template_spec.rb +43 -0
- data/spec/opensearch/api/actions/shutdown/delete_node_spec.rb +53 -0
- data/spec/opensearch/api/actions/shutdown/get_node_spec.rb +55 -0
- data/spec/opensearch/api/actions/shutdown/put_node_spec.rb +59 -0
- data/spec/opensearch/api/actions/snapshot/clone_spec.rb +76 -0
- data/spec/opensearch/api/actions/snapshot/create_repository_spec.rb +60 -0
- data/spec/opensearch/api/actions/snapshot/create_spec.rb +60 -0
- data/spec/opensearch/api/actions/snapshot/delete_repository_spec.rb +59 -0
- data/spec/opensearch/api/actions/snapshot/delete_spec.rb +60 -0
- data/spec/opensearch/api/actions/snapshot/get_features_spec.rb +47 -0
- data/spec/opensearch/api/actions/snapshot/get_repository_spec.rb +44 -0
- data/spec/opensearch/api/actions/snapshot/get_spec.rb +60 -0
- data/spec/opensearch/api/actions/snapshot/repository_analize_spec.rb +57 -0
- data/spec/opensearch/api/actions/snapshot/restore_spec.rb +60 -0
- data/spec/opensearch/api/actions/snapshot/status_spec.rb +59 -0
- data/spec/opensearch/api/actions/snapshot/verify_repository_spec.rb +44 -0
- data/spec/opensearch/api/actions/tasks/cancel_spec.rb +59 -0
- data/spec/opensearch/api/actions/tasks/get_spec.rb +44 -0
- data/spec/opensearch/api/actions/tasks/list_spec.rb +48 -0
- data/spec/opensearch/api/actions/termvectors_spec.rb +75 -0
- data/spec/opensearch/api/actions/update_by_query_spec.rb +44 -0
- data/spec/opensearch/api/actions/update_document_spec.rb +131 -0
- data/spec/opensearch/api/api_spec.rb +52 -0
- data/spec/opensearch/api/client_spec.rb +55 -0
- data/spec/opensearch/api/rest_api_yaml_spec.rb +169 -0
- data/spec/opensearch/api/utils_spec.rb +439 -0
- data/spec/rest_yaml_tests_helper.rb +89 -0
- data/spec/skipped_tests.yml +29 -0
- data/spec/spec_helper.rb +84 -0
- data.tar.gz.sig +0 -0
- metadata +860 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0336e67b1234f2806569282b68533fa183b0f26515a163beb4722f578e949a9c
|
4
|
+
data.tar.gz: 7ea3c280646f1ac0c0f6c78d691da2b488358f68e0fdb1b5bc6938ccc1ca9b6d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 551a4da8e0db3d1e8fffda9d6c030838c996d7f95f5a12f457321eb9bf93f95b950511d99dfb9a2ab1fd216a16e87b86daf2a1cbc08891632c37104898b588e7
|
7
|
+
data.tar.gz: 1fc1d8e8d80319fc4b51f2d0d6977aa3ea4cb93f917b1060959c054507c5e2165c9ca07534e8d31961cb78de6149b844d664c3349137ea1ef40bac1815221e13
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,48 @@
|
|
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-api.gemspec
|
30
|
+
gemspec
|
31
|
+
|
32
|
+
if File.exist? File.expand_path("../../opensearch-transport", __FILE__)
|
33
|
+
gem 'opensearch-transport', path: File.expand_path("../../opensearch-transport", __FILE__), require: true
|
34
|
+
end
|
35
|
+
|
36
|
+
if File.exist? File.expand_path("../../opensearch/opensearch.gemspec", __FILE__)
|
37
|
+
gem 'opensearch-ruby', path: File.expand_path("../../opensearch", __FILE__), require: false
|
38
|
+
end
|
39
|
+
|
40
|
+
group :development do
|
41
|
+
gem 'rspec'
|
42
|
+
gem 'rspec_junit_formatter'
|
43
|
+
if defined?(JRUBY_VERSION)
|
44
|
+
gem 'pry-nav'
|
45
|
+
else
|
46
|
+
gem 'pry-byebug'
|
47
|
+
end
|
48
|
+
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,194 @@
|
|
1
|
+
# OpenSearch::API
|
2
|
+
|
3
|
+
**This library is part of the [`opensearch-ruby`](https://github.com/opensearch-project/opensearch-ruby/) package;
|
4
|
+
please refer to it, unless you want to use this library standalone.**
|
5
|
+
|
6
|
+
----
|
7
|
+
|
8
|
+
The `opensearch-api` library provides a Ruby implementation of
|
9
|
+
the [OpenSearch](http://opensearch.com) REST API.
|
10
|
+
|
11
|
+
It does not provide an OpenSearch client; see the
|
12
|
+
[`opensearch-transport`](https://github.com/opensearch-project/opensearch-ruby/tree/main/opensearch-transport) library.
|
13
|
+
|
14
|
+
The library is compatible with Ruby 1.9 and higher.
|
15
|
+
|
16
|
+
It is compatible with OpenSearch's API versions from 1.0.0 till current.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Install the package from [Rubygems](https://rubygems.org):
|
21
|
+
|
22
|
+
gem install opensearch-api
|
23
|
+
|
24
|
+
To use an unreleased version, either add it to your `Gemfile` for [Bundler](http://gembundler.com):
|
25
|
+
|
26
|
+
gem 'opensearch-api', git: 'git://github.com/opensearch-project/opensearch-ruby.git'
|
27
|
+
|
28
|
+
or install it from a source code checkout:
|
29
|
+
|
30
|
+
git clone https://github.com/opensearch-project/opensearch-ruby
|
31
|
+
cd opensearch-ruby/opensearch-api
|
32
|
+
bundle install
|
33
|
+
rake install
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
The library is designed as a group of standalone Ruby modules, which can be mixed into a class
|
38
|
+
providing connection to OpenSearch -- an OpenSearch client.
|
39
|
+
|
40
|
+
### Usage with the `opensearch` gem
|
41
|
+
|
42
|
+
**When you use the client from the [`opensearch-ruby`](https://github.com/opensearch-project/opensearch-ruby/) package,
|
43
|
+
the library modules have been already included**, so you just call the API methods:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
require 'opensearch'
|
47
|
+
|
48
|
+
client = OpenSearch::Client.new(log: true)
|
49
|
+
|
50
|
+
client.index(index: 'myindex', type: 'mytype', id: 1, body: { title: 'Test' })
|
51
|
+
# => {"_index"=>"myindex", ... "created"=>true}
|
52
|
+
|
53
|
+
client.search(index: 'myindex', body: { query: { match: { title: 'test' } } })
|
54
|
+
# => {"took"=>2, ..., "hits"=>{"total":5, ...}}
|
55
|
+
```
|
56
|
+
|
57
|
+
### Usage with a custom client
|
58
|
+
|
59
|
+
When you want to mix the library into your own client, it must conform to a following _contract_:
|
60
|
+
|
61
|
+
* It responds to a `perform_request(method, path, params, body, headers)` method,
|
62
|
+
* the method returns an object with `status`, `body` and `headers` methods.
|
63
|
+
|
64
|
+
A simple client could look like this (_with a dependency on `active_support` to parse the query params_):
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
require 'multi_json'
|
68
|
+
require 'faraday'
|
69
|
+
require 'opensearch/api'
|
70
|
+
require 'active_support'
|
71
|
+
|
72
|
+
class MySimpleClient
|
73
|
+
include OpenSearch::API
|
74
|
+
|
75
|
+
CONNECTION = ::Faraday::Connection.new url: 'http://localhost:9200'
|
76
|
+
|
77
|
+
def perform_request(method, path, params, body, headers = nil)
|
78
|
+
puts "--> #{method.upcase} #{path} #{params} #{body} #{headers}"
|
79
|
+
|
80
|
+
CONNECTION.run_request \
|
81
|
+
method.downcase.to_sym,
|
82
|
+
path_with_params(path, params),
|
83
|
+
( body ? MultiJson.dump(body): nil ),
|
84
|
+
{'Content-Type' => 'application/json'}
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def path_with_params(path, params)
|
90
|
+
return path if params.blank?
|
91
|
+
|
92
|
+
case params
|
93
|
+
when String
|
94
|
+
"#{path}?#{params}"
|
95
|
+
when Hash
|
96
|
+
"#{path}?#{params.to_query}"
|
97
|
+
else
|
98
|
+
raise ArgumentError, "Cannot parse params: '#{params}'"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
client = MySimpleClient.new
|
104
|
+
|
105
|
+
p client.cluster.health
|
106
|
+
# --> GET _cluster/health {}
|
107
|
+
# => "{"cluster_name":"opensearch" ... }"
|
108
|
+
|
109
|
+
p client.index index: 'myindex', type: 'mytype', id: 'custom', body: { title: "Indexing from my client" }
|
110
|
+
# --> PUT myindex/mytype/custom {} {:title=>"Indexing from my client"}
|
111
|
+
# => "{"ok":true, ... }"
|
112
|
+
```
|
113
|
+
|
114
|
+
### Using JSON Builders
|
115
|
+
|
116
|
+
Instead of passing the `:body` argument as a Ruby _Hash_, you can pass it as a _String_, potentially
|
117
|
+
taking advantage of JSON builders such as [JBuilder](https://github.com/rails/jbuilder) or
|
118
|
+
[Jsonify](https://github.com/bsiggelkow/jsonify):
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
require 'jbuilder'
|
122
|
+
|
123
|
+
query = Jbuilder.encode do |json|
|
124
|
+
json.query do
|
125
|
+
json.match do
|
126
|
+
json.title do
|
127
|
+
json.query 'test 1'
|
128
|
+
json.operator 'and'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
client.search index: 'myindex', body: query
|
135
|
+
|
136
|
+
# 2013-06-25 09:56:05 +0200: GET http://localhost:9200/myindex/_search [status:200, request:0.015s, query:0.011s]
|
137
|
+
# 2013-06-25 09:56:05 +0200: > {"query":{"match":{"title":{"query":"test 1","operator":"and"}}}}
|
138
|
+
# ...
|
139
|
+
# => {"took"=>21, ..., "hits"=>{"total"=>1, "hits"=>[{ "_source"=>{"title"=>"Test 1", ...}}]}}
|
140
|
+
```
|
141
|
+
|
142
|
+
### Using Hash Wrappers
|
143
|
+
|
144
|
+
For a more comfortable access to response properties, you may wrap it in one of the _Hash_ "object access"
|
145
|
+
wrappers, such as [`Hashie::Mash`](https://github.com/intridea/hashie):
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
require 'hashie'
|
149
|
+
|
150
|
+
response = client.search index: 'myindex',
|
151
|
+
body: {
|
152
|
+
query: { match: { title: 'test' } },
|
153
|
+
aggregations: { tags: { terms: { field: 'tags' } } }
|
154
|
+
}
|
155
|
+
|
156
|
+
mash = Hashie::Mash.new response
|
157
|
+
|
158
|
+
mash.hits.hits.first._source.title
|
159
|
+
# => 'Test'
|
160
|
+
|
161
|
+
mash.aggregations.tags.terms.first
|
162
|
+
# => #<Hashie::Mash count=3 term="z">
|
163
|
+
```
|
164
|
+
|
165
|
+
### Using a Custom JSON Serializer
|
166
|
+
|
167
|
+
The library uses the [MultiJson](https://rubygems.org/gems/multi_json/) gem by default,
|
168
|
+
but allows you to set a custom JSON library, provided it uses the standard `load/dump`
|
169
|
+
interface:
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
OpenSearch::API.settings[:serializer] = JrJackson::Json
|
173
|
+
OpenSearch::API.serializer.dump({foo: 'bar'})
|
174
|
+
# => {"foo":"bar"}
|
175
|
+
```
|
176
|
+
|
177
|
+
## Development
|
178
|
+
|
179
|
+
To work on the code, clone and bootstrap the main repository first -- please see instructions in the main [README](../README.md#development).
|
180
|
+
|
181
|
+
To run tests, launch a testing cluster -- again, see instructions in the main [README](../README.md#development) -- and use the Rake tasks:
|
182
|
+
|
183
|
+
```
|
184
|
+
time rake test:unit
|
185
|
+
time rake test:integration
|
186
|
+
```
|
187
|
+
|
188
|
+
We run the test suite for OpenSearch's Rest API tests. You can read more about this in [the test runner README](https://github.com/opensearch-project/opensearch-ruby/tree/main/api-spec-testing#rest-api-yaml-test-runner).
|
189
|
+
|
190
|
+
The `rest_api` needs the test files from OpenSearch. You can run the rake task to download the test artifacts in the root folder of the project. This task needs a running cluster to determine which version and build hash of OpenSearch to use and test against. `TEST_OPENSEARCH_SERVER=http://localhost:9200 rake opensearch:download_artifacts`. This will download the necessary files used for the integration tests to `./tmp`.
|
191
|
+
|
192
|
+
## License
|
193
|
+
|
194
|
+
This software is licensed under the [Apache 2 license](./LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1,131 @@
|
|
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
|
+
require 'json'
|
29
|
+
|
30
|
+
task(:default) { system 'rake --tasks' }
|
31
|
+
task test: 'test:unit'
|
32
|
+
|
33
|
+
# ----- Test tasks ------------------------------------------------------------
|
34
|
+
|
35
|
+
require 'rake/testtask'
|
36
|
+
require 'rspec/core/rake_task'
|
37
|
+
|
38
|
+
namespace :test do
|
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
|
+
# Unit tests - rake test:unit
|
45
|
+
#
|
46
|
+
task unit: :spec
|
47
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
48
|
+
t.exclude_pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Run Rest API Spec tests"
|
52
|
+
RSpec::Core::RakeTask.new(:rest_api) do |t|
|
53
|
+
require 'opensearch'
|
54
|
+
# Check if a test cluster is running
|
55
|
+
begin
|
56
|
+
url = ENV['TEST_CLUSTER_URL'] || ENV['TEST_OPENSEARCH_SERVER']
|
57
|
+
url = "http://localhost:#{ENV['TEST_CLUSTER_PORT'] || 9200}" unless url
|
58
|
+
client = OpenSearch::Client.new :url => url
|
59
|
+
es_version_info = client.info['version']
|
60
|
+
version_number = es_version_info['number']
|
61
|
+
build_hash = es_version_info['build_hash']
|
62
|
+
rescue Faraday::ConnectionFailed
|
63
|
+
STDERR.puts "[!] Test cluster not running?"
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
|
67
|
+
t.pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Run integration tests"
|
71
|
+
task :integration do
|
72
|
+
Rake::Task['test:rest_api'].invoke
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'Run unit and integration tests'
|
76
|
+
task :all do
|
77
|
+
Rake::Task['test:unit'].invoke
|
78
|
+
Rake::Task['test:integration'].invoke
|
79
|
+
end
|
80
|
+
|
81
|
+
def refresh_artifacts(build_hash, version_number)
|
82
|
+
unless build_hash
|
83
|
+
STDERR.puts "[!] Cannot determine checkout build hash -- server not running"
|
84
|
+
exit(1)
|
85
|
+
end
|
86
|
+
|
87
|
+
puts 'Downloading artifacts file...'
|
88
|
+
filename = 'tmp/artifacts.json'
|
89
|
+
`curl -s <placeholder_opensearch_artifact_url> -o #{filename}`
|
90
|
+
|
91
|
+
unless File.exists?("./#{filename}")
|
92
|
+
STDERR.puts '[!] Couldn\'t download artifacts file'
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
|
96
|
+
artifacts = JSON.parse(File.read('./tmp/artifacts.json'))
|
97
|
+
|
98
|
+
build_hash_artifact = artifacts['version']['builds'].select do |a|
|
99
|
+
a.dig('projects', 'opensearch', 'commit_hash') == build_hash
|
100
|
+
end.first
|
101
|
+
# Dig into the opensearch packages, search for the rest-resources-zip package and catch the URL:
|
102
|
+
zip_url = build_hash_artifact.dig('projects', 'opensearch', 'packages').select { |k,v| k =~ /rest-resources-zip/ }.map { | _, v| v['url'] }.first
|
103
|
+
|
104
|
+
filename = zip_url.split('/').last
|
105
|
+
puts 'Downloading zip file:'
|
106
|
+
`curl -s #{zip_url} -o tmp/#{filename}`
|
107
|
+
|
108
|
+
unless File.exists?("./tmp/#{filename}")
|
109
|
+
STDERR.puts '[!] Couldn\'t download artifact'
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
|
113
|
+
puts "Unzipping file #{filename}"
|
114
|
+
`unzip -o tmp/#{filename} -d tmp/`
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# ----- Documentation tasks ---------------------------------------------------
|
119
|
+
|
120
|
+
require 'yard'
|
121
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
122
|
+
t.options = %w| --embed-mixins --markup=markdown |
|
123
|
+
end
|
124
|
+
|
125
|
+
# ----- Code analysis tasks ---------------------------------------------------
|
126
|
+
|
127
|
+
require 'cane/rake_task'
|
128
|
+
Cane::RakeTask.new(:quality) do |cane|
|
129
|
+
cane.abc_max = 15
|
130
|
+
cane.no_style = true
|
131
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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 API
|
29
|
+
module Actions
|
30
|
+
# Abort a running benchmark
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
#
|
34
|
+
# client.abort_benchmark name: 'my_benchmark'
|
35
|
+
#
|
36
|
+
# @option arguments [String] :name A benchmark name
|
37
|
+
#
|
38
|
+
#
|
39
|
+
def abort_benchmark(arguments = {})
|
40
|
+
method = HTTP_POST
|
41
|
+
path = "_bench/abort/#{arguments[:name]}"
|
42
|
+
params = {}
|
43
|
+
body = nil
|
44
|
+
|
45
|
+
perform_request(method, path, params, body).body
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|