Class: Sunspot::Search::Group

Inherits:
Object
  • Object
show all
Includes:
HitEnumerable
Defined in:
lib/sunspot/search/group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HitEnumerable

#data_accessor_for, #each_hit_with_result, #populate_hits

Constructor Details

#initialize(value, doclist, search) ⇒ Group

Returns a new instance of Group.



10
11
12
# File 'lib/sunspot/search/group.rb', line 10

def initialize(value, doclist, search)
  @value, @doclist, @search = value, doclist, search
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/sunspot/search/group.rb', line 6

def value
  @value
end

Instance Method Details

#highlights_for(doc) ⇒ Object



30
31
32
# File 'lib/sunspot/search/group.rb', line 30

def highlights_for(doc)
  @search.highlights_for(doc)
end

#hits(options = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/sunspot/search/group.rb', line 14

def hits(options = {})
  if options[:verify]
    super
  else
    @hits ||= super
  end
end

#resultsObject



26
27
28
# File 'lib/sunspot/search/group.rb', line 26

def results
  @results ||= verified_hits.map { |hit| hit.instance }
end

#solr_docsObject



34
35
36
# File 'lib/sunspot/search/group.rb', line 34

def solr_docs
  @doclist['docs']
end

#totalObject

The total number of documents matching the query for this group

Returns

Integer

Total matching documents



45
46
47
# File 'lib/sunspot/search/group.rb', line 45

def total
  @doclist['numFound']
end

#verified_hitsObject



22
23
24
# File 'lib/sunspot/search/group.rb', line 22

def verified_hits
  @verified_hits ||= super
end