Class: Frett::Search
- Inherits:
-
Object
- Object
- Frett::Search
- Defined in:
- lib/frett/search.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Search
constructor
A new instance of Search.
- #search(needle, path = nil) ⇒ Object
Constructor Details
Instance Method Details
#search(needle, path = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/frett/search.rb', line 8 def search(needle, path = nil) results = [] adapter.read do |index| index.search_each(build_query(needle, path), :limit => Frett::Config.num_docs) do |doc_id, score| results.push result(index[doc_id]) end end puts ( results.size == 1 ? "1 match" : "#{results.size} matches" ).white results.flatten.map { |result_line| puts result_line } end |