Method: ClWiki::MemoryIndexer#search
- Defined in:
- lib/cl_wiki/memory_index.rb
#search(text, titles_only: false) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cl_wiki/memory_index.rb', line 43 def search(text, titles_only: false) terms = text.split(' ') all_hits = [] terms.each do |term| term_hits = [] @index.search(term, term_hits, WAIT) term_hits.flatten! all_hits = all_hits.empty? ? term_hits : all_hits & term_hits end all_hits.flatten! all_hits.uniq! all_hits.sort! all_hits.delete_if { |name| name !~ /#{text}/i } if titles_only all_hits end |