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.
-
#rendering_options ⇒ Object
readonly
Returns the value of attribute rendering_options.
-
#trim ⇒ Object
readonly
Returns the value of attribute trim.
Class Method Summary collapse
-
.render(result, options = {}, &block) ⇒ Object
Show scoring with indents.
-
.render_in_line(result, options = {}, &block) ⇒ Object
Show scoring as a simple math formula.
- .result_as_hash(result, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(explain, options = {}) ⇒ ExplainResponse
constructor
A new instance of ExplainResponse.
- #render(&block) ⇒ Object
- #render_as_hash(&block) ⇒ Object
- #render_in_line(&block) ⇒ Object
Constructor Details
#initialize(explain, options = {}) ⇒ ExplainResponse
Returns a new instance of ExplainResponse.
47 48 49 50 51 52 53 54 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 47 def initialize(explain, = {}) @explain = explain || {} @indent = 0 @trim = .has_key?(:trim) ? .delete(:trim) : true @rendering_options = parse_details end |
Instance Attribute Details
#explain ⇒ Object (readonly)
Returns the value of attribute explain.
45 46 47 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 45 def explain @explain end |
#rendering_options ⇒ Object (readonly)
Returns the value of attribute rendering_options.
45 46 47 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 45 def @rendering_options end |
#trim ⇒ Object (readonly)
Returns the value of attribute trim.
45 46 47 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 45 def trim @trim end |
Class Method Details
.render(result, options = {}, &block) ⇒ Object
Show scoring with indents
36 37 38 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 36 def render(result, = {}, &block) new(result["explanation"], ).render(&block) end |
.render_in_line(result, options = {}, &block) ⇒ Object
Show scoring as a simple math formula
25 26 27 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 25 def render_in_line(result, = {}, &block) new(result["explanation"], ).render_in_line(&block) end |
.result_as_hash(result, options = {}) ⇒ Object
40 41 42 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 40 def result_as_hash(result, = {}) new(result["explanation"], ).render_as_hash end |
Instance Method Details
#render(&block) ⇒ Object
56 57 58 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 56 def render(&block) @root.render(, &block) end |
#render_as_hash(&block) ⇒ Object
64 65 66 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 64 def render_as_hash(&block) @root.render_as_hash(, &block) end |
#render_in_line(&block) ⇒ Object
60 61 62 |
# File 'lib/elasticsearch/api/response/explain_response.rb', line 60 def render_in_line(&block) @root.render_in_line(, &block) end |