class Searcher

Attributes

results[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/searcher.rb, line 4
def initialize options = {}
  @options = options

  @query = options[:query]
  @q = options[:q]

  @search_group = options[:search_group] || "pages,attachments"
  @type = options[:type]
  @comparator = options[:comparator] || "AND"
end

Public Instance Methods

results_with_hits() { |grouped_results[_source.id].first, hit| ... } click to toggle source
# File lib/searcher.rb, line 43
def results_with_hits 
  grouped_results = {}

  hits = @results.hits
  hits.group_by(&:_type).each do |type, values|
    klass = type.classify.constantize
    ids = values.collect{|value| value._source.id }
    grouped_results[type] = klass.find(ids).group_by(&:id)
  end

  hits.each do |hit|
    yield grouped_results[hit._type][hit._source.id].first, hit
  end
end
search_group() click to toggle source
# File lib/searcher.rb, line 58
def search_group
  @search_group
end