Not sure where you're at with this - I realise I've been a little slow to 
respond.

I guess as a first step, I think you'll need to actually pass the facet name as 
a param value - so you know what to expect in the controller. ie:

  @facets = Listing.facets(params[:search)
  if params[:facet]
    @listings = @facets.for(params[:facet].to_sym => params[:facet_value])
  else
    @listings = Listing.search params[:search], :page => params[:page]
  end

I must admit, I've not implemented facets on any of my projects, so this is a 
little of a grey area for me. I'm sure we can get a solution figured out though 
(if you've not done so already).

Cheers

-- 
Pat

On 26/06/2010, at 1:22 PM, Tainted Moo wrote:

> Howdy folks!
> 
> I'm very new to Thinking Sphinx and am still getting my bearings
> around Rails in general.  I'm presently trying to implement facets in
> my product search.  I'm able to search normally and am also able to
> display the facets, but clicking on a facet link to try and drill-down
> and see the results via a facet filter doesn't seem to actually alter
> the search results. Not sure if it helps, but clicking a link in the
> browser returns a URL like this: <domain>/listings?category=2&page=1.
> As you can see, it looks kinda right, but seems to drop the search
> query as well.
> 
> I've read through the facets page on the docs and while I see how one
> can return products via facets in the console, I'm having a real hard
> time actually putting the pieces together and implementing in my rails
> application.  In isolation everything seems fine, just not in practice
> as a whole. I apologize for what I assume is a fairly basic
> question... What am I missing that would otherwise make facet links
> functional (while also maintaining the search query)?
> 
> 
> Here's a snipped portion of my model:
> 
> belongs_to :product
> define_index do
> has product.category(:id), :as => :category, :facet => true
> end
> 
> controller:
> 
> def index
> @listings = Listing.search(params[:search], :with => {}, :page =>
> params[:page])
> @facets = Listing.facets(params[:search])
> 
> 
> View's search btn:
> <% form_tag @search, :method => :get do %>
>  <p>
>    <%= text_field_tag :search, params[:search] %>
>    <%= submit_tag "Search", :name => nil %>
>  </p>
> 
> 
> View's facet filter:
>       <% @facets.each do |facet, facet_options| %>
>         <h5><%= facet %></h5>
>         <ul>
>         <% facet_options.each do |option, count| %>
>           <li><%= link_to "#{option} (#{count})",
>             :params => {facet => option, :page => 1} %></li>
>         <% end %>
>         </ul>
>       <% end %>
> 
> 
> For the actual list of products, I'm simply iterating through and
> displaying each product in @listings.
> 
> Thank you!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to