opensearch-api 1.0.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +28 -0
  5. data/Gemfile +2 -2
  6. data/README.md +12 -182
  7. data/Rakefile +5 -5
  8. data/USER_GUIDE.md +155 -0
  9. data/lib/opensearch/api/actions/benchmark.rb +0 -1
  10. data/lib/opensearch/api/actions/bulk.rb +1 -7
  11. data/lib/opensearch/api/actions/cat/all_pit_segments.rb +46 -0
  12. data/lib/opensearch/api/actions/cat/allocation.rb +4 -2
  13. data/lib/opensearch/api/actions/cat/cluster_manager.rb +54 -0
  14. data/lib/opensearch/api/actions/cat/indices.rb +4 -2
  15. data/lib/opensearch/api/actions/cat/master.rb +3 -1
  16. data/lib/opensearch/api/actions/cat/nodeattrs.rb +4 -2
  17. data/lib/opensearch/api/actions/cat/nodes.rb +4 -2
  18. data/lib/opensearch/api/actions/cat/pending_tasks.rb +4 -2
  19. data/lib/opensearch/api/actions/cat/pit_segments.rb +49 -0
  20. data/lib/opensearch/api/actions/cat/plugins.rb +4 -2
  21. data/lib/opensearch/api/actions/cat/repositories.rb +4 -2
  22. data/lib/opensearch/api/actions/cat/shards.rb +4 -2
  23. data/lib/opensearch/api/actions/cat/snapshots.rb +3 -1
  24. data/lib/opensearch/api/actions/cat/templates.rb +4 -2
  25. data/lib/opensearch/api/actions/cat/thread_pool.rb +4 -2
  26. data/lib/opensearch/api/actions/cluster/delete_component_template.rb +4 -2
  27. data/lib/opensearch/api/actions/cluster/exists_component_template.rb +4 -2
  28. data/lib/opensearch/api/actions/cluster/get_component_template.rb +4 -2
  29. data/lib/opensearch/api/actions/cluster/get_settings.rb +3 -1
  30. data/lib/opensearch/api/actions/cluster/health.rb +4 -2
  31. data/lib/opensearch/api/actions/cluster/pending_tasks.rb +5 -3
  32. data/lib/opensearch/api/actions/cluster/put_component_template.rb +4 -2
  33. data/lib/opensearch/api/actions/cluster/put_settings.rb +3 -1
  34. data/lib/opensearch/api/actions/cluster/reroute.rb +4 -2
  35. data/lib/opensearch/api/actions/cluster/state.rb +4 -2
  36. data/lib/opensearch/api/actions/count.rb +1 -6
  37. data/lib/opensearch/api/actions/create.rb +0 -1
  38. data/lib/opensearch/api/actions/create_pit.rb +45 -0
  39. data/lib/opensearch/api/actions/dangling_indices/delete_dangling_index.rb +4 -2
  40. data/lib/opensearch/api/actions/dangling_indices/import_dangling_index.rb +4 -2
  41. data/lib/opensearch/api/actions/delete.rb +1 -8
  42. data/lib/opensearch/api/actions/delete_all_pits.rb +26 -0
  43. data/lib/opensearch/api/actions/delete_by_query.rb +1 -8
  44. data/lib/opensearch/api/actions/delete_pit.rb +30 -0
  45. data/lib/opensearch/api/actions/delete_script.rb +4 -2
  46. data/lib/opensearch/api/actions/exists.rb +1 -8
  47. data/lib/opensearch/api/actions/exists_source.rb +1 -8
  48. data/lib/opensearch/api/actions/explain.rb +1 -8
  49. data/lib/opensearch/api/actions/features/get_features.rb +4 -2
  50. data/lib/opensearch/api/actions/get.rb +1 -8
  51. data/lib/opensearch/api/actions/get_all_pits.rb +26 -0
  52. data/lib/opensearch/api/actions/get_script.rb +4 -2
  53. data/lib/opensearch/api/actions/get_source.rb +1 -8
  54. data/lib/opensearch/api/actions/index.rb +1 -8
  55. data/lib/opensearch/api/actions/indices/add_block.rb +3 -1
  56. data/lib/opensearch/api/actions/indices/clone.rb +3 -1
  57. data/lib/opensearch/api/actions/indices/close.rb +3 -1
  58. data/lib/opensearch/api/actions/indices/create.rb +4 -4
  59. data/lib/opensearch/api/actions/indices/delete.rb +3 -1
  60. data/lib/opensearch/api/actions/indices/delete_alias.rb +4 -2
  61. data/lib/opensearch/api/actions/indices/delete_index_template.rb +4 -2
  62. data/lib/opensearch/api/actions/indices/delete_template.rb +4 -2
  63. data/lib/opensearch/api/actions/indices/exists_index_template.rb +4 -2
  64. data/lib/opensearch/api/actions/indices/exists_template.rb +4 -2
  65. data/lib/opensearch/api/actions/indices/get.rb +4 -4
  66. data/lib/opensearch/api/actions/indices/get_field_mapping.rb +1 -10
  67. data/lib/opensearch/api/actions/indices/get_index_template.rb +4 -2
  68. data/lib/opensearch/api/actions/indices/get_mapping.rb +5 -12
  69. data/lib/opensearch/api/actions/indices/get_settings.rb +3 -1
  70. data/lib/opensearch/api/actions/indices/get_template.rb +4 -4
  71. data/lib/opensearch/api/actions/indices/open.rb +3 -1
  72. data/lib/opensearch/api/actions/indices/put_alias.rb +4 -2
  73. data/lib/opensearch/api/actions/indices/put_index_template.rb +4 -2
  74. data/lib/opensearch/api/actions/indices/put_mapping.rb +4 -13
  75. data/lib/opensearch/api/actions/indices/put_settings.rb +3 -1
  76. data/lib/opensearch/api/actions/indices/put_template.rb +4 -4
  77. data/lib/opensearch/api/actions/indices/rollover.rb +3 -3
  78. data/lib/opensearch/api/actions/indices/shrink.rb +3 -1
  79. data/lib/opensearch/api/actions/indices/simulate_index_template.rb +4 -2
  80. data/lib/opensearch/api/actions/indices/simulate_template.rb +4 -2
  81. data/lib/opensearch/api/actions/indices/split.rb +3 -1
  82. data/lib/opensearch/api/actions/indices/update_aliases.rb +4 -2
  83. data/lib/opensearch/api/actions/indices/validate_query.rb +1 -6
  84. data/lib/opensearch/api/actions/ingest/delete_pipeline.rb +3 -1
  85. data/lib/opensearch/api/actions/ingest/get_pipeline.rb +4 -2
  86. data/lib/opensearch/api/actions/ingest/put_pipeline.rb +3 -1
  87. data/lib/opensearch/api/actions/mget.rb +2 -7
  88. data/lib/opensearch/api/actions/msearch.rb +1 -6
  89. data/lib/opensearch/api/actions/msearch_template.rb +1 -6
  90. data/lib/opensearch/api/actions/mtermvectors.rb +1 -6
  91. data/lib/opensearch/api/actions/put_script.rb +3 -1
  92. data/lib/opensearch/api/actions/search.rb +1 -7
  93. data/lib/opensearch/api/actions/search_shards.rb +1 -1
  94. data/lib/opensearch/api/actions/search_template.rb +1 -6
  95. data/lib/opensearch/api/actions/snapshot/cleanup_repository.rb +3 -1
  96. data/lib/opensearch/api/actions/snapshot/clone.rb +4 -2
  97. data/lib/opensearch/api/actions/snapshot/create.rb +3 -1
  98. data/lib/opensearch/api/actions/snapshot/create_repository.rb +3 -1
  99. data/lib/opensearch/api/actions/snapshot/delete.rb +4 -2
  100. data/lib/opensearch/api/actions/snapshot/delete_repository.rb +3 -1
  101. data/lib/opensearch/api/actions/snapshot/get.rb +3 -1
  102. data/lib/opensearch/api/actions/snapshot/get_features.rb +4 -2
  103. data/lib/opensearch/api/actions/snapshot/get_repository.rb +3 -2
  104. data/lib/opensearch/api/actions/snapshot/restore.rb +3 -1
  105. data/lib/opensearch/api/actions/snapshot/status.rb +3 -1
  106. data/lib/opensearch/api/actions/snapshot/verify_repository.rb +3 -1
  107. data/lib/opensearch/api/actions/termvectors.rb +1 -8
  108. data/lib/opensearch/api/actions/update.rb +1 -8
  109. data/lib/opensearch/api/actions/update_by_query.rb +1 -8
  110. data/lib/opensearch/api/utils.rb +5 -5
  111. data/lib/opensearch/api/version.rb +1 -1
  112. data/lib/opensearch/api.rb +1 -1
  113. data/opensearch-api.gemspec +2 -3
  114. data/spec/opensearch/api/actions/bulk_spec.rb +10 -21
  115. data/spec/opensearch/api/actions/cat/all_pit_segments_spec.rb +36 -0
  116. data/spec/opensearch/api/actions/cat/allocation_spec.rb +6 -7
  117. data/spec/opensearch/api/actions/cat/cluster_manager_spec.rb +26 -0
  118. data/spec/opensearch/api/actions/cat/pit_segments_spec.rb +43 -0
  119. data/spec/opensearch/api/actions/count_spec.rb +3 -3
  120. data/spec/opensearch/api/actions/create_document_spec.rb +8 -8
  121. data/spec/opensearch/api/actions/create_pit_spec.rb +58 -0
  122. data/spec/opensearch/api/actions/delete_all_pits_spec.rb +35 -0
  123. data/spec/opensearch/api/actions/delete_by_query_spec.rb +0 -17
  124. data/spec/opensearch/api/actions/delete_document_spec.rb +10 -10
  125. data/spec/opensearch/api/actions/delete_pit_spec.rb +41 -0
  126. data/spec/opensearch/api/actions/exists_document_spec.rb +10 -10
  127. data/spec/opensearch/api/actions/explain_document_spec.rb +8 -8
  128. data/spec/opensearch/api/actions/get_all_pits_spec.rb +35 -0
  129. data/spec/opensearch/api/actions/get_document_source_spec.rb +6 -6
  130. data/spec/opensearch/api/actions/get_document_spec.rb +8 -8
  131. data/spec/opensearch/api/actions/get_script_spec.rb +2 -2
  132. data/spec/opensearch/api/actions/hashie_spec.rb +0 -2
  133. data/spec/opensearch/api/actions/index_document_spec.rb +12 -12
  134. data/spec/opensearch/api/actions/indices/clone_spec.rb +2 -2
  135. data/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb +0 -11
  136. data/spec/opensearch/api/actions/indices/get_mapping_spec.rb +5 -16
  137. data/spec/opensearch/api/actions/indices/put_mapping_spec.rb +8 -21
  138. data/spec/opensearch/api/actions/indices/validate_query_spec.rb +0 -10
  139. data/spec/opensearch/api/actions/mget_spec.rb +2 -17
  140. data/spec/opensearch/api/actions/mtermvectors_spec.rb +3 -3
  141. data/spec/opensearch/api/actions/search_spec.rb +5 -16
  142. data/spec/opensearch/api/actions/termvectors_spec.rb +5 -5
  143. data/spec/opensearch/api/actions/update_document_spec.rb +11 -11
  144. data/spec/opensearch/api/utils_spec.rb +7 -14
  145. data.tar.gz.sig +0 -0
  146. metadata +40 -43
  147. metadata.gz.sig +0 -0
  148. data/lib/opensearch/api/actions/close_point_in_time.rb +0 -50
  149. data/lib/opensearch/api/actions/indices/exists_type.rb +0 -79
  150. data/lib/opensearch/api/actions/indices/flush_synced.rb +0 -79
  151. data/lib/opensearch/api/actions/open_point_in_time.rb +0 -72
  152. data/spec/opensearch/api/actions/close_point_in_time_spec.rb +0 -43
  153. data/spec/opensearch/api/actions/indices/exists_type_spec.rb +0 -117
  154. data/spec/opensearch/api/actions/indices/flush_synced_spec.rb +0 -99
  155. data/spec/opensearch/api/actions/open_point_in_time_spec.rb +0 -53
@@ -32,7 +32,8 @@ module OpenSearch
32
32
  #
33
33
  # @option arguments [String] :repository A repository name
34
34
  # @option arguments [String] :snapshot A snapshot name
35
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
35
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
36
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
36
37
  # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning
37
38
  # @option arguments [Hash] :headers Custom HTTP headers
38
39
  # @option arguments [Hash] :body The snapshot definition
@@ -63,6 +64,7 @@ module OpenSearch
63
64
  # @since 6.2.0
64
65
  ParamsRegistry.register(:create, [
65
66
  :master_timeout,
67
+ :cluster_manager_timeout,
66
68
  :wait_for_completion
67
69
  ].freeze)
68
70
  end
@@ -31,7 +31,8 @@ module OpenSearch
31
31
  # Creates a repository.
32
32
  #
33
33
  # @option arguments [String] :repository A repository name
34
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
34
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
35
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
35
36
  # @option arguments [Time] :timeout Explicit operation timeout
36
37
  # @option arguments [Boolean] :verify Whether to verify the repository after creation
37
38
  # @option arguments [Hash] :headers Custom HTTP headers
@@ -61,6 +62,7 @@ module OpenSearch
61
62
  # @since 6.2.0
62
63
  ParamsRegistry.register(:create_repository, [
63
64
  :master_timeout,
65
+ :cluster_manager_timeout,
64
66
  :timeout,
65
67
  :verify
66
68
  ].freeze)
@@ -32,7 +32,8 @@ module OpenSearch
32
32
  #
33
33
  # @option arguments [String] :repository A repository name
34
34
  # @option arguments [String] :snapshot A snapshot name
35
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
35
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
36
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
36
37
  # @option arguments [Hash] :headers Custom HTTP headers
37
38
  #
38
39
  #
@@ -64,7 +65,8 @@ module OpenSearch
64
65
  #
65
66
  # @since 6.2.0
66
67
  ParamsRegistry.register(:delete, [
67
- :master_timeout
68
+ :master_timeout,
69
+ :cluster_manager_timeout
68
70
  ].freeze)
69
71
  end
70
72
  end
@@ -31,7 +31,8 @@ module OpenSearch
31
31
  # Deletes a repository.
32
32
  #
33
33
  # @option arguments [List] :repository Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported.
34
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
34
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
35
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
35
36
  # @option arguments [Time] :timeout Explicit operation timeout
36
37
  # @option arguments [Hash] :headers Custom HTTP headers
37
38
  #
@@ -62,6 +63,7 @@ module OpenSearch
62
63
  # @since 6.2.0
63
64
  ParamsRegistry.register(:delete_repository, [
64
65
  :master_timeout,
66
+ :cluster_manager_timeout,
65
67
  :timeout
66
68
  ].freeze)
67
69
  end
@@ -32,7 +32,8 @@ module OpenSearch
32
32
  #
33
33
  # @option arguments [String] :repository A repository name
34
34
  # @option arguments [List] :snapshot A comma-separated list of snapshot names
35
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
35
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
36
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
36
37
  # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown
37
38
  # @option arguments [Boolean] :index_details Whether to include details of each index in the snapshot, if those details are available. Defaults to false.
38
39
  # @option arguments [Boolean] :include_repository Whether to include the repository name in the snapshot info. Defaults to true.
@@ -69,6 +70,7 @@ module OpenSearch
69
70
  # @since 6.2.0
70
71
  ParamsRegistry.register(:get, [
71
72
  :master_timeout,
73
+ :cluster_manager_timeout,
72
74
  :ignore_unavailable,
73
75
  :index_details,
74
76
  :include_repository,
@@ -30,7 +30,8 @@ module OpenSearch
30
30
  module Actions
31
31
  # Returns a list of features which can be snapshotted in this cluster.
32
32
  #
33
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
33
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
34
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
34
35
  # @option arguments [Hash] :headers Custom HTTP headers
35
36
  #
36
37
  #
@@ -51,7 +52,8 @@ module OpenSearch
51
52
  #
52
53
  # @since 6.2.0
53
54
  ParamsRegistry.register(:get_features, [
54
- :master_timeout
55
+ :master_timeout,
56
+ :cluster_manager_timeout
55
57
  ].freeze)
56
58
  end
57
59
  end
@@ -31,8 +31,8 @@ module OpenSearch
31
31
  # Returns information about a repository.
32
32
  #
33
33
  # @option arguments [List] :repository A comma-separated list of repository names
34
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
35
- # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
34
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to cluster_manager node
35
+ # @option arguments [Boolean] :local Return local information, do not retrieve the state from cluster_manager node (default: false)
36
36
  # @option arguments [Hash] :headers Custom HTTP headers
37
37
  #
38
38
  #
@@ -64,6 +64,7 @@ module OpenSearch
64
64
  # @since 6.2.0
65
65
  ParamsRegistry.register(:get_repository, [
66
66
  :master_timeout,
67
+ :cluster_manager_timeout,
67
68
  :local
68
69
  ].freeze)
69
70
  end
@@ -32,7 +32,8 @@ module OpenSearch
32
32
  #
33
33
  # @option arguments [String] :repository A repository name
34
34
  # @option arguments [String] :snapshot A snapshot name
35
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
35
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
36
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
36
37
  # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning
37
38
  # @option arguments [Hash] :headers Custom HTTP headers
38
39
  # @option arguments [Hash] :body Details of what to restore
@@ -63,6 +64,7 @@ module OpenSearch
63
64
  # @since 6.2.0
64
65
  ParamsRegistry.register(:restore, [
65
66
  :master_timeout,
67
+ :cluster_manager_timeout,
66
68
  :wait_for_completion
67
69
  ].freeze)
68
70
  end
@@ -32,7 +32,8 @@ module OpenSearch
32
32
  #
33
33
  # @option arguments [String] :repository A repository name
34
34
  # @option arguments [List] :snapshot A comma-separated list of snapshot names
35
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
35
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
36
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
36
37
  # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown
37
38
  # @option arguments [Hash] :headers Custom HTTP headers
38
39
  #
@@ -69,6 +70,7 @@ module OpenSearch
69
70
  # @since 6.2.0
70
71
  ParamsRegistry.register(:status, [
71
72
  :master_timeout,
73
+ :cluster_manager_timeout,
72
74
  :ignore_unavailable
73
75
  ].freeze)
74
76
  end
@@ -31,7 +31,8 @@ module OpenSearch
31
31
  # Verifies a repository.
32
32
  #
33
33
  # @option arguments [String] :repository A repository name
34
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
34
+ # @option arguments [Time] :master_timeout (DEPRECATED: use cluster_manager_timeout instead) Explicit operation timeout for connection to master node
35
+ # @option arguments [Time] :cluster_manager_timeout Explicit operation timeout for connection to cluster_manager node
35
36
  # @option arguments [Time] :timeout Explicit operation timeout
36
37
  # @option arguments [Hash] :headers Custom HTTP headers
37
38
  #
@@ -58,6 +59,7 @@ module OpenSearch
58
59
  # @since 6.2.0
59
60
  ParamsRegistry.register(:verify_repository, [
60
61
  :master_timeout,
62
+ :cluster_manager_timeout,
61
63
  :timeout
62
64
  ].freeze)
63
65
  end
@@ -31,7 +31,6 @@ module OpenSearch
31
31
  #
32
32
  # @option arguments [String] :index The index in which the document resides. (*Required*)
33
33
  # @option arguments [String] :id The id of the document, when not specified a doc param should be supplied.
34
- # @option arguments [String] :type The type of the document.
35
34
  # @option arguments [Boolean] :term_statistics Specifies if total term frequency and document frequency should be returned.
36
35
  # @option arguments [Boolean] :field_statistics Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.
37
36
  # @option arguments [List] :fields A comma-separated list of fields to return.
@@ -63,8 +62,6 @@ module OpenSearch
63
62
 
64
63
  _id = arguments.delete(:id)
65
64
 
66
- _type = arguments.delete(:type)
67
-
68
65
  method = if arguments[:body]
69
66
  OpenSearch::API::HTTP_POST
70
67
  else
@@ -72,11 +69,7 @@ module OpenSearch
72
69
  end
73
70
 
74
71
  endpoint = arguments.delete(:endpoint) || '_termvectors'
75
- path = if _index && _type && _id
76
- "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/#{endpoint}"
77
- elsif _index && _type
78
- "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{endpoint}"
79
- elsif _index && _id
72
+ path = if _index && _id
80
73
  "#{Utils.__listify(_index)}/#{endpoint}/#{Utils.__listify(_id)}"
81
74
  else
82
75
  "#{Utils.__listify(_index)}/#{endpoint}"
@@ -31,7 +31,6 @@ module OpenSearch
31
31
  #
32
32
  # @option arguments [String] :id Document ID
33
33
  # @option arguments [String] :index The name of the index
34
- # @option arguments [String] :type The type of the document *Deprecated*
35
34
  # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
36
35
  # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
37
36
  # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
@@ -66,14 +65,8 @@ module OpenSearch
66
65
 
67
66
  _index = arguments.delete(:index)
68
67
 
69
- _type = arguments.delete(:type)
70
-
71
68
  method = OpenSearch::API::HTTP_POST
72
- path = if _index && _type && _id
73
- "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_update"
74
- else
75
- "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}"
76
- end
69
+ path = "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}"
77
70
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
78
71
 
79
72
  body = arguments[:body]
@@ -31,7 +31,6 @@ module OpenSearch
31
31
  # for example to pick up a mapping change.
32
32
  #
33
33
  # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*)
34
- # @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types
35
34
  # @option arguments [String] :analyzer The analyzer to use for the query string
36
35
  # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
37
36
  # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR)
@@ -85,14 +84,8 @@ module OpenSearch
85
84
 
86
85
  _index = arguments.delete(:index)
87
86
 
88
- _type = arguments.delete(:type)
89
-
90
87
  method = OpenSearch::API::HTTP_POST
91
- path = if _index && _type
92
- "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_update_by_query"
93
- else
94
- "#{Utils.__listify(_index)}/_update_by_query"
95
- end
88
+ path = "#{Utils.__listify(_index)}/_update_by_query"
96
89
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
97
90
 
98
91
  body = arguments[:body]
@@ -40,7 +40,7 @@ module OpenSearch
40
40
  # @api private
41
41
  def __escape(string)
42
42
  return string if string == '*'
43
- defined?(EscapeUtils) ? EscapeUtils.escape_url(string.to_s) : CGI.escape(string.to_s)
43
+ CGI.escape(string.to_s)
44
44
  end
45
45
 
46
46
  # Create a "list" of values from arguments, ignoring nil values and encoding special characters.
@@ -97,13 +97,13 @@ module OpenSearch
97
97
  # in a single item.
98
98
  #
99
99
  # OpenSearch::API::Utils.__bulkify [
100
- # { :index => { :_index => 'myindexA', :_type => 'mytype', :_id => '1', :data => { :title => 'Test' } } },
101
- # { :update => { :_index => 'myindexB', :_type => 'mytype', :_id => '2', :data => { :doc => { :title => 'Update' } } } }
100
+ # { :index => { :_index => 'myindexA', :_id => '1', :data => { :title => 'Test' } } },
101
+ # { :update => { :_index => 'myindexB', :_id => '2', :data => { :doc => { :title => 'Update' } } } }
102
102
  # ]
103
103
  #
104
- # # => {"index":{"_index":"myindexA","_type":"mytype","_id":"1"}}
104
+ # # => {"index":{"_index":"myindexA","_id":"1"}}
105
105
  # # => {"title":"Test"}
106
- # # => {"update":{"_index":"myindexB","_type":"mytype","_id":"2"}}
106
+ # # => {"update":{"_index":"myindexB","_id":"2"}}
107
107
  # # => {"doc":{"title":"Update"}}
108
108
  #
109
109
  def __bulkify(payload)
@@ -26,6 +26,6 @@
26
26
 
27
27
  module OpenSearch
28
28
  module API
29
- VERSION = '1.0.0'.freeze
29
+ VERSION = '2.2.0'.freeze
30
30
  end
31
31
  end
@@ -42,7 +42,7 @@ module OpenSearch
42
42
 
43
43
  COMMON_PARAMS = [
44
44
  :ignore, # Client specific parameters
45
- :index, :type, :id, # :index/:type/:id
45
+ :index, :id, # :index/:id
46
46
  :body, # Request body
47
47
  :node_id, # Cluster
48
48
  :name, # Alias, template, settings, warmer, ...
@@ -64,7 +64,7 @@ Gem::Specification.new do |s|
64
64
 
65
65
  s.add_development_dependency 'ansi'
66
66
  s.add_development_dependency 'bundler'
67
- s.add_development_dependency 'opensearch'
67
+ s.add_development_dependency 'opensearch-ruby', '~> 2'
68
68
  s.add_development_dependency 'opensearch-transport'
69
69
  s.add_development_dependency 'minitest'
70
70
  s.add_development_dependency 'minitest-reporters'
@@ -79,7 +79,6 @@ Gem::Specification.new do |s|
79
79
  s.add_development_dependency 'hashie'
80
80
 
81
81
  s.add_development_dependency 'cane'
82
- s.add_development_dependency 'escape_utils' unless defined? JRUBY_VERSION
83
82
  s.add_development_dependency 'jbuilder'
84
83
  s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
85
84
  s.add_development_dependency 'simplecov'
@@ -87,6 +86,6 @@ Gem::Specification.new do |s|
87
86
  s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
88
87
 
89
88
  s.description = <<-DESC.gsub(/^ /, '')
90
- Ruby API for OpenSearch. See the `opensearch` gem for full integration.
89
+ Ruby API for OpenSearch. See the `opensearch-ruby` gem for full integration.
91
90
  DESC
92
91
  end
@@ -47,22 +47,22 @@ describe 'client#bulk' do
47
47
 
48
48
  let(:body) do
49
49
  <<-PAYLOAD.gsub(/^\s+/, '')
50
- {"index":{"_index":"myindexA","_type":"mytype","_id":"1"}}
50
+ {"index":{"_index":"myindexA","_id":"1"}}
51
51
  {"title":"Test"}
52
- {"update":{"_index":"myindexB","_type":"mytype","_id":"2"}}
52
+ {"update":{"_index":"myindexB","_id":"2"}}
53
53
  {"doc":{"title":"Update"}}
54
- {"delete":{"_index":"myindexC","_type":"mytypeC","_id":"3"}}
55
- {"index":{"_index":"myindexD","_type":"mytype","_id":"1"}}
54
+ {"delete":{"_index":"myindexC","_id":"3"}}
55
+ {"index":{"_index":"myindexD","_id":"1"}}
56
56
  {"data":"MYDATA"}
57
57
  PAYLOAD
58
58
  end
59
59
 
60
60
  it 'performs the request' do
61
61
  expect(client_double.bulk(:body => [
62
- { :index => { :_index => 'myindexA', :_type => 'mytype', :_id => '1', :data => { :title => 'Test' } } },
63
- { :update => { :_index => 'myindexB', :_type => 'mytype', :_id => '2', :data => { :doc => { :title => 'Update' } } } },
64
- { :delete => { :_index => 'myindexC', :_type => 'mytypeC', :_id => '3' } },
65
- { :index => { :_index => 'myindexD', :_type => 'mytype', :_id => '1', :data => { :data => 'MYDATA' } } },
62
+ { :index => { :_index => 'myindexA', :_id => '1', :data => { :title => 'Test' } } },
63
+ { :update => { :_index => 'myindexB', :_id => '2', :data => { :doc => { :title => 'Update' } } } },
64
+ { :delete => { :_index => 'myindexC', :_id => '3' } },
65
+ { :index => { :_index => 'myindexD', :_id => '1', :data => { :data => 'MYDATA' } } },
66
66
  ])).to eq({})
67
67
  end
68
68
  end
@@ -80,13 +80,13 @@ describe 'client#bulk' do
80
80
 
81
81
  let(:body) do
82
82
  <<-PAYLOAD.gsub(/^\s+/, '')
83
- {"update":{"_index":"myindex","_type":"mytype","_id":"1"}}
83
+ {"update":{"_index":"myindex","_id":"1"}}
84
84
  {"doc":{"data":{"title":"Update"}}}
85
85
  PAYLOAD
86
86
  end
87
87
 
88
88
  it 'performs the request' do
89
- expect(client_double.bulk(body:[ { :update => { :_index => 'myindex', :_type => 'mytype', :_id => '1' } },
89
+ expect(client_double.bulk(body:[ { :update => { :_index => 'myindex', :_id => '1' } },
90
90
  { :doc => { :data => { :title => 'Update' } } } ])).to eq({})
91
91
  end
92
92
  end
@@ -134,15 +134,4 @@ describe 'client#bulk' do
134
134
  expect(client_double.bulk(index: 'foo^bar', body: [])).to eq({})
135
135
  end
136
136
  end
137
-
138
- context 'when the type is provided' do
139
-
140
- let(:url) do
141
- 'myindex/mytype/_bulk'
142
- end
143
-
144
- it 'performs the request' do
145
- expect(client_double.bulk(index: 'myindex', type: 'mytype', body: [])).to eq({})
146
- end
147
- end
148
137
  end
@@ -0,0 +1,36 @@
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
+ require 'spec_helper'
11
+
12
+ describe 'client.cat#all_pit_segments' do
13
+
14
+ let(:expected_args) do
15
+ [
16
+ 'GET',
17
+ '_cat/pit_segments/_all',
18
+ {},
19
+ nil,
20
+ {}
21
+ ]
22
+ end
23
+ let(:client) do
24
+ Class.new { include OpenSearch::API }.new
25
+ end
26
+
27
+ it 'does not accept unregistered params' do
28
+ expect {
29
+ client.cat.all_pit_segments(something: :else)
30
+ }.to raise_exception(ArgumentError)
31
+ end
32
+
33
+ it 'performs the request' do
34
+ expect(client_double.cat.all_pit_segments).to eq({})
35
+ end
36
+ end
@@ -27,18 +27,17 @@
27
27
  require 'spec_helper'
28
28
 
29
29
  describe 'client.cat#allocation' do
30
-
31
30
  let(:expected_args) do
32
31
  [
33
- 'GET',
34
- '_cat/allocation',
35
- {},
36
- nil,
37
- {}
32
+ 'GET',
33
+ '_cat/allocation',
34
+ {cluster_manager_timeout: 2},
35
+ nil,
36
+ {}
38
37
  ]
39
38
  end
40
39
 
41
40
  it 'performs the request' do
42
- expect(client_double.cat.allocation).to eq({})
41
+ expect(client_double.cat.allocation(cluster_manager_timeout: 2)).to eq({})
43
42
  end
44
43
  end
@@ -0,0 +1,26 @@
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
+ require 'spec_helper'
11
+
12
+ describe 'client.cat#cluster_manager' do
13
+ let(:expected_args) do
14
+ [
15
+ 'GET',
16
+ '_cat/cluster_manager',
17
+ {},
18
+ nil,
19
+ {}
20
+ ]
21
+ end
22
+
23
+ it 'performs the request' do
24
+ expect(client_double.cat.cluster_manager).to eq({})
25
+ end
26
+ end
@@ -0,0 +1,43 @@
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
+ require 'spec_helper'
11
+
12
+ describe 'client.cat#pit_segments' do
13
+
14
+ let(:expected_args) do
15
+ [
16
+ 'GET',
17
+ '_cat/pit_segments',
18
+ {},
19
+ { pit_id: ['abc'] },
20
+ {}
21
+ ]
22
+ end
23
+
24
+ let(:client) do
25
+ Class.new { include OpenSearch::API }.new
26
+ end
27
+
28
+ it 'requires the :body argument' do
29
+ expect {
30
+ client.cat.pit_segments
31
+ }.to raise_exception(ArgumentError)
32
+ end
33
+
34
+ it 'does not accept unregistered params' do
35
+ expect {
36
+ client.cat.pit_segments(body: {}, something: :else)
37
+ }.to raise_exception(ArgumentError)
38
+ end
39
+
40
+ it 'performs the request' do
41
+ expect(client_double.cat.pit_segments(body: { pit_id: ['abc'] })).to eq({})
42
+ end
43
+ end
@@ -42,12 +42,12 @@ describe 'client#count' do
42
42
  expect(client_double.count).to eq({})
43
43
  end
44
44
 
45
- context 'when an index and type are specified' do
45
+ context 'when an index is specified' do
46
46
 
47
47
  let(:expected_args) do
48
48
  [
49
49
  'POST',
50
- 'foo,bar/t1,t2/_count',
50
+ 'foo,bar/_count',
51
51
  {},
52
52
  nil,
53
53
  {}
@@ -55,7 +55,7 @@ describe 'client#count' do
55
55
  end
56
56
 
57
57
  it 'performs the request' do
58
- expect(client_double.count(index: ['foo','bar'], type: ['t1','t2'])).to eq({})
58
+ expect(client_double.count(index: ['foo','bar'])).to eq({})
59
59
  end
60
60
  end
61
61
 
@@ -31,7 +31,7 @@ describe 'client#create_document' do
31
31
  let(:expected_args) do
32
32
  [
33
33
  'PUT',
34
- 'foo/bar/123',
34
+ 'foo/_doc/123',
35
35
  { op_type: 'create' },
36
36
  { foo: 'bar' },
37
37
  {}
@@ -39,7 +39,7 @@ describe 'client#create_document' do
39
39
  end
40
40
 
41
41
  it 'performs the request' do
42
- expect(client_double.create(index: 'foo', type: 'bar', id: '123', body: { foo: 'bar'})).to eq({})
42
+ expect(client_double.create(index: 'foo', id: '123', body: { foo: 'bar'})).to eq({})
43
43
  end
44
44
 
45
45
  context 'when the request needs to be URL-escaped' do
@@ -47,7 +47,7 @@ describe 'client#create_document' do
47
47
  let(:expected_args) do
48
48
  [
49
49
  'PUT',
50
- 'foo/bar%2Fbam/123',
50
+ 'foo%5Ebar/_doc/123',
51
51
  { op_type: 'create' },
52
52
  {},
53
53
  {}
@@ -55,7 +55,7 @@ describe 'client#create_document' do
55
55
  end
56
56
 
57
57
  it 'performs the request' do
58
- expect(client_double.create(index: 'foo', type: 'bar/bam', id: '123', body: {})).to eq({})
58
+ expect(client_double.create(index: 'foo^bar', id: '123', body: {})).to eq({})
59
59
  end
60
60
  end
61
61
 
@@ -64,7 +64,7 @@ describe 'client#create_document' do
64
64
  let(:expected_args) do
65
65
  [
66
66
  'PUT',
67
- 'foo/bar/1',
67
+ 'foo/_doc/1',
68
68
  { op_type: 'create' },
69
69
  { foo: 'bar' },
70
70
  {}
@@ -72,7 +72,7 @@ describe 'client#create_document' do
72
72
  end
73
73
 
74
74
  it 'updates the arguments with the `op_type`' do
75
- expect(client_double.create(index: 'foo', type: 'bar', id: 1, body: { foo: 'bar' })).to eq({})
75
+ expect(client_double.create(index: 'foo', id: 1, body: { foo: 'bar' })).to eq({})
76
76
  end
77
77
  end
78
78
 
@@ -81,7 +81,7 @@ describe 'client#create_document' do
81
81
  let(:expected_args) do
82
82
  [
83
83
  'POST',
84
- 'foo/bar',
84
+ 'foo/_doc',
85
85
  { },
86
86
  { foo: 'bar' },
87
87
  {}
@@ -89,7 +89,7 @@ describe 'client#create_document' do
89
89
  end
90
90
 
91
91
  it 'updates the arguments with the `op_type`' do
92
- expect(client_double.create(index: 'foo', type: 'bar', body: { foo: 'bar' })).to eq({})
92
+ expect(client_double.create(index: 'foo', body: { foo: 'bar' })).to eq({})
93
93
  end
94
94
  end
95
95
  end