Skip to content

Expose result or errors on search #6

@sobrinho

Description

@sobrinho

Hi there!

Would be nice to have request failures exposed, for instance:

result = SomeIndex.search(query: 'something', query_by: 'typo_here')
=> #<Typesensual::Search::Results:0x00007f721ca676c0 @results={"code"=>404, "error"=>"Could not find a field named `typo_here` in the schema."}>

result.hits
Traceback (most recent call last):
        1: from (irb):51
NoMethodError (undefined method `map' for nil:NilClass)

result.results
Traceback (most recent call last):
        1: from (irb):54
NoMethodError (undefined method `results' for #<Typesensual::Search::Results:0x00007f721ca676c0>)

I had to workaround that with:

      if result.count.nil?
        raise RequestFailed, result.instance_variable_get(:@results).inspect
      end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions