Class: ActsAsFerret::MultiIndex
Overview
This class can be used to search multiple physical indexes at once.
Instance Attribute Summary
#logger
Instance Method Summary
collapse
#ar_find, #determine_stored_fields, #initialize, #shared?
#ar_find, #count_records, #find_id_model_arrays, #find_ids, #find_records, #lazy_find, #scope_query_to_models
Instance Method Details
#close ⇒ Object
100
101
102
103
|
# File 'lib/multi_index.rb', line 100
def close
@searcher.close if @searcher
@reader.close if @reader
end
|
#doc(i) ⇒ Object
Also known as:
[]
86
87
88
|
# File 'lib/multi_index.rb', line 86
def doc(i)
searcher[i]
end
|
51
52
53
|
# File 'lib/multi_index.rb', line 51
def (doc, stored_fields)
ActsAsFerret::get_index_for(doc[:class_name]).(doc, stored_fields) unless stored_fields.blank?
end
|
#latest? ⇒ Boolean
checks if all our sub-searchers still are up to date
71
72
73
74
75
76
77
78
79
|
# File 'lib/multi_index.rb', line 71
def latest?
@reader and @reader.latest?
end
|
#process_query(query, options = {}) ⇒ Object
95
96
97
98
|
# File 'lib/multi_index.rb', line 95
def process_query(query, options = {})
query = query_parser.parse(query) if query.is_a?(String)
return query
end
|
#query_parser ⇒ Object
91
92
93
|
# File 'lib/multi_index.rb', line 91
def query_parser
@query_parser ||= Ferret::QueryParser.new(@options)
end
|
#search(query, options = {}) ⇒ Object
59
60
61
62
63
|
# File 'lib/multi_index.rb', line 59
def search(query, options={})
query = process_query(query, options)
logger.debug "parsed query: #{query.to_s}"
searcher.search(query, options)
end
|
#search_each(query, options = {}, &block) ⇒ Object
65
66
67
68
|
# File 'lib/multi_index.rb', line 65
def search_each(query, options = {}, &block)
query = process_query(query, options)
searcher.search_each(query, options, &block)
end
|
#searcher ⇒ Object
81
82
83
84
|
# File 'lib/multi_index.rb', line 81
def searcher
ensure_searcher
@searcher
end
|
#total_hits(q, options = {}) ⇒ Object
55
56
57
|
# File 'lib/multi_index.rb', line 55
def total_hits(q, options = {})
search(q, options).total_hits
end
|