Class: Exa::Services::Search
- Inherits:
-
Object
- Object
- Exa::Services::Search
- Defined in:
- lib/exa/services/search.rb
Constant Summary collapse
- VALID_SEARCH_TYPES =
["auto", "neural", "fast", "deep", "deep-reasoning", "instant"].freeze
- DEFAULT_SEARCH_TYPE =
"auto"
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 30 31 32 33 |
# File 'lib/exa/services/search.rb', line 17 def call response = @connection.post("/search", ParameterConverter.convert(@params)) body = response.body results = body["results"] results = parse_json_summaries(results) if summary_schema? Resources::SearchResult.new( results: results, request_id: body["requestId"], resolved_search_type: body["resolvedSearchType"], search_type: body["searchType"], context: body["context"], cost_dollars: body["costDollars"], output: body["output"] ) end |