diff --git a/lib/opensearch/api/actions/search.rb b/lib/opensearch/api/actions/search.rb index d639cffd1..551ac8d84 100644 --- a/lib/opensearch/api/actions/search.rb +++ b/lib/opensearch/api/actions/search.rb @@ -101,6 +101,9 @@ def search(arguments = {}) else '_search' end + + path = "#{path}?search_pipeline=#{arguments[:body].delete(:search_pipeline)}" unless arguments.dig(:body, :search_pipeline).nil? + params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) body = arguments[:body] diff --git a/spec/opensearch/api/actions/search_spec.rb b/spec/opensearch/api/actions/search_spec.rb index bcad54743..35a41eedf 100644 --- a/spec/opensearch/api/actions/search_spec.rb +++ b/spec/opensearch/api/actions/search_spec.rb @@ -124,4 +124,21 @@ end.to raise_exception(ArgumentError) end end + + context 'when a search pipeline is specified' do + let(:body) do + { + query: { match: {} }, + search_pipeline: 'my_pipeline' + } + end + let(:method) { 'POST' } + let(:url) do + '_search?search_pipeline=my_pipeline' + end + + it 'performs the request' do + expect(client_double.search(body: body)) + end + end end