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
107
108
109
110
|
# File 'lib/acts_as_ferret/multi_index.rb', line 107
def close
@searcher.close if @searcher
@reader.close if @reader
end
|
#doc(i) ⇒ Object
Also known as:
[]
93
94
95
|
# File 'lib/acts_as_ferret/multi_index.rb', line 93
def doc(i)
searcher[i]
end
|
58
59
60
|
# File 'lib/acts_as_ferret/multi_index.rb', line 58
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
78
79
80
81
82
83
84
85
86
|
# File 'lib/acts_as_ferret/multi_index.rb', line 78
def latest?
@reader and @reader.latest?
end
|
#process_query(query, options = {}) ⇒ Object
102
103
104
105
|
# File 'lib/acts_as_ferret/multi_index.rb', line 102
def process_query(query, options = {})
query = query_parser.parse(query) if query.is_a?(String)
return query
end
|
#query_parser ⇒ Object
98
99
100
|
# File 'lib/acts_as_ferret/multi_index.rb', line 98
def query_parser
@query_parser ||= Ferret::QueryParser.new(@options)
end
|
#search(query, options = {}) ⇒ Object
66
67
68
69
70
|
# File 'lib/acts_as_ferret/multi_index.rb', line 66
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
72
73
74
75
|
# File 'lib/acts_as_ferret/multi_index.rb', line 72
def search_each(query, options = {}, &block)
query = process_query(query, options)
searcher.search_each(query, options, &block)
end
|
#searcher ⇒ Object
88
89
90
91
|
# File 'lib/acts_as_ferret/multi_index.rb', line 88
def searcher
ensure_searcher
@searcher
end
|
#total_hits(q, options = {}) ⇒ Object
62
63
64
|
# File 'lib/acts_as_ferret/multi_index.rb', line 62
def total_hits(q, options = {})
search(q, options).total_hits
end
|