Sha256: 0aeaae2922b46b22a97e44ce5fe499b80cc0ee19d70092505eb95c76a1624aea
Contents?: true
Size: 889 Bytes
Versions: 3
Compression:
Stored size: 889 Bytes
Contents
module ActiveLucene class Searcher < IndexSearcher include Index attr_reader :attributes, :total_pages def initialize super directory, true end def self.search(param) returning new do |searcher| searcher.search param end end def search(param) query = Query.for(param) top_docs = super(query, nil, Document::PER_PAGE) @attributes = top_docs.scoreDocs.map do |score_doc| attributes = {} doc(score_doc.doc).fields.each do |field| attributes.store field.name, field.string_value highlight = Highlighter.new(QueryScorer.new(query)).get_best_fragment(Analyzer.new, ALL, field.string_value) attributes[:highlight] = highlight if highlight end attributes end @total_pages = (top_docs.totalHits / Document::PER_PAGE.to_f).ceil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_lucene-0.5.2 | lib/active_lucene/searcher.rb |
active_lucene-0.5.1 | lib/active_lucene/searcher.rb |
active_lucene-0.5.0 | lib/active_lucene/searcher.rb |