class SolrLite::Explainer

Attributes

entries[RW]

Public Class Methods

from_response(solr_response) click to toggle source

solr_response (string) is the Solr HTTP response from a query

# File lib/explainer.rb, line 17
def self.from_response(solr_response)
  hash = JSON.parse(solr_response)
  Explainer.new(hash)
end
new(solr_reponse_hash) click to toggle source

solr_response_hash a Solr HTTP response parsed via JSON.parse()

# File lib/explainer.rb, line 7
def initialize(solr_reponse_hash)
  @explain = solr_reponse_hash.fetch("debug", {}).fetch("explain", [])
  @entries = @explain.map do |ex|
    key = ex[0]
    text = ex[1]
    ExplainEntry.new(ex[0], ex[1])
  end
end

Public Instance Methods

text() click to toggle source

Raw string with the explain information for each entry

# File lib/explainer.rb, line 23
def text()
  text = ""
  @entries.each do |entry|
    text += "-- #{entry.key} {\r\n"
    text += "#{entry.text}\r\n"
    text += "}\r\n"
    text += "\r\n"
  end
  text
end