Class: ActiveLucene::SearchResult
- Inherits:
-
Array
- Object
- Array
- ActiveLucene::SearchResult
- Includes:
- Dictionary
- Defined in:
- lib/active_lucene/search_result.rb
Constant Summary
Constants included from Dictionary
Instance Attribute Summary collapse
-
#current_page ⇒ Object
Returns the value of attribute current_page.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#total_pages ⇒ Object
Returns the value of attribute total_pages.
Instance Method Summary collapse
- #add_document(attributes) ⇒ Object
-
#initialize(query) ⇒ SearchResult
constructor
A new instance of SearchResult.
- #next_page ⇒ Object
- #previous_page ⇒ Object
- #suggest ⇒ Object
Methods included from Dictionary
Constructor Details
#initialize(query) ⇒ SearchResult
Returns a new instance of SearchResult.
8 9 10 |
# File 'lib/active_lucene/search_result.rb', line 8 def initialize(query) @query = query end |
Instance Attribute Details
#current_page ⇒ Object
Returns the value of attribute current_page.
6 7 8 |
# File 'lib/active_lucene/search_result.rb', line 6 def current_page @current_page end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
5 6 7 |
# File 'lib/active_lucene/search_result.rb', line 5 def query @query end |
#total_pages ⇒ Object
Returns the value of attribute total_pages.
6 7 8 |
# File 'lib/active_lucene/search_result.rb', line 6 def total_pages @total_pages end |
Instance Method Details
#add_document(attributes) ⇒ Object
12 13 14 |
# File 'lib/active_lucene/search_result.rb', line 12 def add_document(attributes) self << eval(attributes.delete(TYPE)).new(attributes) end |
#next_page ⇒ Object
28 29 30 |
# File 'lib/active_lucene/search_result.rb', line 28 def next_page @current_page + 1 end |
#previous_page ⇒ Object
24 25 26 |
# File 'lib/active_lucene/search_result.rb', line 24 def previous_page @current_page - 1 end |
#suggest ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/active_lucene/search_result.rb', line 16 def suggest spell_checker = SpellChecker.new directory spell_checker.index_dictionary LuceneDictionary.new(Index::Reader.open, ALL) query.split(' ').map do |word| spell_checker.suggest_similar(word, 1).first || word end.join(' ') end |