Skip to content

Commit

Permalink
Add search_pipeline to path
Browse files Browse the repository at this point in the history
Signed-off-by: Tam Chau <[email protected]>
  • Loading branch information
tamcv committed Apr 11, 2024
1 parent bfd43cf commit c74ab4c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/opensearch/api/actions/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
17 changes: 17 additions & 0 deletions spec/opensearch/api/actions/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c74ab4c

Please sign in to comment.