Hi Pat,

Thanks for the response! No problem on the response time.  You clearly
have put a lot of time and effort into TS and the community. To expect
an immediate response would've been rather selfish of me.

After rummaging through other messages in this group and on Stack
Overflow, I managed to get things kind of working using facets.for
without any arguments, but I didn't really understand how it worked.
It was very much a copy & paste approach. I also was unable to get
facet chaining (e.g., filter by category and brand at the same
time...it'd always be one or the other at a time). As such, I've
commented out 'my' version and have played with the code you have
supplied to hopefully learn the proper way of doing things.

Let's say I have facets defined as 'category_named' as an attribute. I
should thus have a conditional check like this, correct?

  if params[:category_named]
    @listings = @facets.for(params[:category_named].to_sym =>
params[:category_named_value])

Presently this returns a Riddle::ResponseError (searchd error (status:
1): invalid or truncated request) after clicking one of the facet
links. The requested parameters in such cases are generally along the
lines of  {"category_named"=>"6",  "page"=>"1"}.  I have noticed that
changing ':category_named_value' to just ':category_named' works in
the sense that my page loads w/o an error, but 0 listings are found.

Is there something else I should be doing?

Thanks!
TM


On Jul 6, 7:13 pm, Pat Allan <[email protected]> wrote:
> 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, TaintedMoowrote:
>
>
>
> > 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 
> > athttp://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