Skip to content

Commit

Permalink
Federated search added
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre authored and Nymuxyzo committed Oct 14, 2024
1 parent 4ef82c6 commit d5f6edd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/meilisearch/multi_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

module MeiliSearch
module MultiSearch
def multi_search(data)
# Performs search on one or more indexes
#
# @param [Hash] federation_options
# - `limit`: number of results in the merged list
# - `offset`: number of results to skip in the merged list
def multi_search(data, federation_options = nil)
body = Utils.transform_attributes(data)

http_post '/multi-search', queries: body
http_post '/multi-search', queries: body, federation: federation_options
end
end
end
15 changes: 15 additions & 0 deletions spec/meilisearch/client/multi_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,19 @@
expect(response['results'][0]['estimatedTotalHits']).to eq(0)
expect(response['results'][1]['estimatedTotalHits']).to eq(0)
end

it 'does a federated search with two different indexes' do
response = client.multi_search([
{ index_uid: 'books', q: 'prince' },
{ index_uid: 'movies', q: 'prince' }
],
{
limit: 20,
offset: 0
})

expect(response['hits'].count).to eq(0)
expect(response['estimatedTotalHits']).to eq(0)
expect(response).not_to have_key('results')
end
end

0 comments on commit d5f6edd

Please sign in to comment.