class SearchFlip::Result
The SearchFlip::Result
class basically is a hash wrapper that uses Hashie::Mash to provide convenient method access to the hash attributes.
Public Class Methods
disable_warnings?(*args)
click to toggle source
# File lib/search_flip/result.rb, line 6 def self.disable_warnings?(*args) true end
from_hit(hit)
click to toggle source
Creates a SearchFlip::Result
object from a raw hit. Useful for e.g. top hits aggregations.
@example
query = ProductIndex.aggregate(top_sales: { top_hits: "..." }) top_sales_hits = query.aggregations(:top_sales).top_hits.hits.hits SearchFlip::Result.from_hit(top_sales_hits.first)
# File lib/search_flip/result.rb, line 19 def self.from_hit(hit) raw_result = (hit["_source"] || {}).dup raw_result["_hit"] = hit.each_with_object({}) do |(key, value), hash| hash[key] = value if key != "_source" end new(raw_result) end