Module: DiscourseApi::API::Search

Included in:
Client
Defined in:
lib/discourse_api/api/search.rb

Instance Method Summary collapse

Instance Method Details

#search(term, options = {}) ⇒ Array

Returns search results that match the specified term.

Parameters:

  • term (String)

    a search term

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

    A customizable set of options

Options Hash (options):

  • :type_filter (String)

    Returns results of the specified type.

Returns:

  • (Array)

    Return results as an array of Hashes.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File 'lib/discourse_api/api/search.rb', line 11

def search(term, options = {})
  raise ArgumentError.new("#{term} is required but not specified") unless term
  raise ArgumentError.new("#{term} is required but not specified") if term.empty?

  response = get("/search", options.merge(q: term))
  response[:body]
end