Ok, I think I've actually got it working:


def self.find_storage_by_contents(query, options = {})
    results = []

    default_options = {:limit => 10, :page => 1}
    options = default_options.merge options
    options[:offset] = options[:limit] * (options[:page].to_i - 1)

    search = find_by_contents(query, options)
    total_hits = search.total_hits

    search.each do |hit|
      result = {}

      # Store each field in a hash which we can reference in our views
      result[:headline_highlight] = hit.highlight(query,
        :field => :headline,
        :pre_tag => "<strong>",
        :post_tag => "</strong>",
        :num_excerpts => 1)
      result[:body_highlight] = hit.highlight(query,
        :field => :body,
        :pre_tag => "<strong>",
        :post_tag => "</strong>",
        :num_excerpts => 1)
      result[:article] = hit

      results.push result
    end unless query.nil?

    return block_given? ? total_hits : [total_hits, results]
  end



Is there anything in there that I'm not doing correctly?
-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to