How would I change this method in order to get highlighting working with
DRb? I’ve given up on searching on Google, I’m getting no results that
are actually helpful.
def self.find_storage_by_contents(query, options = {})
# Get the index that acts_as_ferret created for us
index = self.aaf_index.ferret_index
results = []
default_options = {:limit => 10, :page => 1}
options = default_options.merge options
options[:offset] = options[:limit] * (options[:page].to_i - 1)
# search_each is the core search function from Ferret, which
Acts_as_ferret hides
total_hits = index.search_each(query, options) do |hit, score|
doc = index[hit]
result = {}
article = Article.find(doc[:id])
# Store each field in a hash which we can reference in our views
result[:headline_highlight] = index.highlight(query, hit,
:field => :headline,
:pre_tag => "<strong>",
:post_tag => "</strong>",
:num_excerpts => 1)
result[:body_highlight] = index.highlight(query, hit,
:field => :body,
:pre_tag => "<strong>",
:post_tag => "</strong>",
:num_excerpts => 1)
result[:article] = article
result[:score] = score
results.push result
end unless query.nil?
return block_given? ? total_hits : [total_hits, results]
end