Class: NaranyaEcm::Search::Results
Constant Summary
collapse
- DEFAULT_MATERIALIZER =
Proc.new do |search_results|
result_elements = search_results.hits.dup
pending_hits = result_elements.select { |e| e.is_a? NaranyaEcm::Search::Hit }
pending_hits.map(&:klass).uniq.each do |hit_klass|
hit_ids = pending_hits.select { |e| e.klass == hit_klass }.map(&:id)
hit_klass.where(id: hit_ids).fetch_from_server.each do |fetched_data|
r = hit_klass.load fetched_data
hit_data = result_elements.detect { |e| e.is_a?(NaranyaEcm::Search::Hit) && e.klass == r.class && e.id == r.id }
hit_index = result_elements.find_index hit_data
r.merge_search_hit_data hit_data
result_elements[hit_index] = r
end
end
result_elements
end
Instance Attribute Summary collapse
#conditions, #elements, #klass
Instance Method Summary
collapse
#[], #fetch_from_server, #initialize, #limit, #load, #where
Instance Attribute Details
#materializer ⇒ Object
Returns the value of attribute materializer.
35
36
37
|
# File 'lib/naranya_ecm/search/results.rb', line 35
def materializer
@materializer
end
|
Instance Method Details
#any? ⇒ Boolean
61
62
63
|
# File 'lib/naranya_ecm/search/results.rb', line 61
def any?
count > 0
end
|
#count ⇒ Object
57
58
59
|
# File 'lib/naranya_ecm/search/results.rb', line 57
def count
hits.count
end
|
#digest ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/naranya_ecm/search/results.rb', line 43
def digest
[
'naranya_ecm',
'search',
'results',
Digest::MD5.hexdigest(@dsl.to_s)
]
end
|
#empty? ⇒ Boolean
65
66
67
|
# File 'lib/naranya_ecm/search/results.rb', line 65
def empty?
count < 1
end
|
#facts ⇒ Object
69
70
71
72
|
# File 'lib/naranya_ecm/search/results.rb', line 69
def facts
do_search! unless @facts
@facts
end
|
#hits ⇒ Object
52
53
54
55
|
# File 'lib/naranya_ecm/search/results.rb', line 52
def hits
do_search! unless @hits
@hits
end
|
#max_score ⇒ Object
74
75
76
77
|
# File 'lib/naranya_ecm/search/results.rb', line 74
def max_score
do_search! unless @max_score
@max_score
end
|
#query_process_time ⇒ Object
79
80
81
82
|
# File 'lib/naranya_ecm/search/results.rb', line 79
def query_process_time
do_search! unless @query_process_time
@query_process_time
end
|
#query_total_time ⇒ Object
84
85
86
87
|
# File 'lib/naranya_ecm/search/results.rb', line 84
def query_total_time
do_search! unless @query_total_time
@query_total_time
end
|
#to_a ⇒ Object
93
94
95
96
|
# File 'lib/naranya_ecm/search/results.rb', line 93
def to_a
materialize! unless @elements
elements
end
|
#total_hits ⇒ Object
Also known as:
total_count
37
38
39
40
|
# File 'lib/naranya_ecm/search/results.rb', line 37
def total_hits
do_search! unless @total_hits
@total_hits
end
|