Class: Elasticsearch::API::Response::ExplainResponse
- Inherits:
-
Object
- Object
- Elasticsearch::API::Response::ExplainResponse
- Defined in:
- lib/elasticsearch/api/response/explain_response.rb
Overview
Parse Elasticsearch Explain API response json and display them in a neat way
Instance Attribute Summary collapse
-
#explain ⇒ Object
readonly
Returns the value of attribute explain.
Class Method Summary collapse
-
.render(result, max: nil) ⇒ Object
Show scoring with indents.
-
.render_in_line(result, max: nil) ⇒ Object
Show scoring as a simple math formula.
Instance Method Summary collapse
-
#initialize(explain, max: nil, colorize: true) ⇒ ExplainResponse
constructor
A new instance of ExplainResponse.
- #render ⇒ Object
- #render_in_line ⇒ Object
Constructor Details
#initialize(explain, max: nil, colorize: true) ⇒ ExplainResponse
Returns a new instance of ExplainResponse.
40 41 42 43 44 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 40 def initialize(explain, max: nil, colorize: true) @explain = explain @indent = 0 @renderer = ExplainRenderer.new(max: max, colorize: colorize) end |
Instance Attribute Details
#explain ⇒ Object (readonly)
Returns the value of attribute explain.
38 39 40 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 38 def explain @explain end |
Class Method Details
.render(result, max: nil) ⇒ Object
Show scoring with indents
33 34 35 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 33 def render(result, max: nil) new(result["explanation"], max: max).render end |
.render_in_line(result, max: nil) ⇒ Object
Show scoring as a simple math formula
22 23 24 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 22 def render_in_line(result, max: nil) new(result["explanation"], max: max).render_in_line end |
Instance Method Details
#render ⇒ Object
46 47 48 49 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 46 def render parse_details @renderer.render(@root) end |
#render_in_line ⇒ Object
51 52 53 54 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 51 def render_in_line parse_details @renderer.render_in_line(@root) end |