Method: Meilisearch::Index#search

Defined in:
lib/meilisearch/index.rb

#search(query, options = {}) ⇒ Object

options: A Hash

show_ranking_score - To see the ranking scores for returned documents
attributes_to_search_on - Customize attributes to search on at search time.


331
332
333
334
335
336
337
338
339
340
# File 'lib/meilisearch/index.rb', line 331

def search(query, options = {})
  attributes = { q: query.to_s }.merge(options.compact)

  parsed_options = Utils.transform_attributes(attributes)
  response = http_post "/indexes/#{@uid}/search", parsed_options

  response['nbHits'] ||= response['estimatedTotalHits'] unless response.key?('totalPages')

  response
end