From 4a7c8f33df568a29372af3610ca9d5a2329fafd6 Mon Sep 17 00:00:00 2001 From: Tam Chau Date: Thu, 11 Apr 2024 11:55:39 +0700 Subject: [PATCH] Add search_pipeline to path Signed-off-by: Tam Chau --- lib/opensearch/api/actions/search.rb | 3 +++ spec/opensearch/api/actions/search_spec.rb | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) 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