To edit pages or tickets please login with username/password: aaf/aaf

Ticket #207 (new enhancement)

Opened 7 months ago

Respond to to_xml with just the local FerretResult

Reported by: aaf Assigned to: jk
Priority: minor Milestone:
Component: 0plugin Version:
Keywords: Cc:

Description

Just a suggestion...

I typically store in the Ferret index the contents of the fields that I return in the search results so that when the search engine results page is rendered, a DB lookup is not needed to render each result (using the :lazy=>[:title, :description])

When displaying results via web-services, I've added this method:

module ActsAsFerret
  class FerretResult
    def to_xml(*args)
      {:model=>@model, :id=>@id, :score=>@ferret_score, :data=>@data}.to_xml(args[0])
    end
  end
end

But by default, the root of the XML doc is "acts-as-ferret/ferret-results", which causes problems because of the slash, so I do this in my controller:

render :xml => @my_model.to_xml(:root=>'search_results')

To edit pages or tickets please login with username/password: aaf/aaf