Class: Exa::Services::Search
- Inherits:
-
Object
- Object
- Exa::Services::Search
- Defined in:
- lib/exa/services/search.rb
Constant Summary collapse
- VALID_SEARCH_TYPES =
["fast", "deep", "keyword", "auto"].freeze
- DEFAULT_SEARCH_TYPE =
"fast"
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(connection, **params) ⇒ Search
constructor
A new instance of Search.
Constructor Details
#initialize(connection, **params) ⇒ Search
Returns a new instance of Search.
11 12 13 14 15 |
# File 'lib/exa/services/search.rb', line 11 def initialize(connection, **params) @connection = connection @params = normalize_params(params) validate_search_type! end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/exa/services/search.rb', line 17 def call response = @connection.post("/search", ParameterConverter.convert(@params)) body = response.body Resources::SearchResult.new( results: body["results"], request_id: body["requestId"], resolved_search_type: body["resolvedSearchType"], search_type: body["searchType"], context: body["context"], cost_dollars: body["costDollars"] ) end |