Module: Elastic::AppSearch::Client::Search

Included in:
Elastic::AppSearch::Client
Defined in:
lib/elastic/app-search/client/search.rb

Instance Method Summary collapse

Instance Method Details

#multi_search(engine_name, searches) ⇒ Array<Hash>

Run multiple searches for documents on a single request

see the App Search API for supported search options.

Parameters:

  • engine_name (String)

    the unique Engine name

  • searches ({query: String, options: Hash})

    to execute

Returns:

  • (Array<Hash>)

    an Array of searh sesults



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/elastic/app-search/client/search.rb', line 24

def multi_search(engine_name, searches)
  params = searches.map do |search|
    search = Utils.symbolize_keys(search)
    query = search[:query]
    options = search[:options] || {}
    Utils.symbolize_keys(options).merge(:query => query)
  end
  request(:post, "engines/#{engine_name}/multi_search", {
    queries: params
  })
end

#search(engine_name, query, options = {}) ⇒ Hash

Search for documents

Parameters:

  • engine_name (String)

    the unique Engine name

  • query (String)

    the search query

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

Returns:

  • (Hash)

    search results



12
13
14
15
# File 'lib/elastic/app-search/client/search.rb', line 12

def search(engine_name, query, options = {})
  params = Utils.symbolize_keys(options).merge(:query => query)
  request(:post, "engines/#{engine_name}/search", params)
end