Hi Chris

You should be able to get the count first by the following code:

   @facets = Model.facets

That will return a Hash-like object (well, a subclass of Hash), which  
will look something like:

   {:s_service_address => {"Value A" => 3, "Value B" => 4, "Value C"  
=> 1}}

These results can be used in your views to provide a summary of the  
breakdown of search results. You can then drill down on those results  
as follows:

   @facets.for(:s_service_address => "Value B")

I'm not quite sure if this is what you're after, going by your  
description, but hopefully it's helpful nonetheless.

Cheers

-- 
Pat

On 29/04/2009, at 8:26 PM, internetchris wrote:

>
> Hey Everyone,
>
> I'm on to my next task. I would like to implement / try out the facet
> feature in my search results. As a test I added this to my
> "define_index" block...
>
>
> define_index do
>    indexes s_property_no, :sortable => true
>    indexes s_service_address, :facet => true
>    indexes names.name, :as => :property_name
>    indexes names.address :as => :property_address
>  end
>
>
> I understand I can view my facet field using "Model.facets" , but I'm
> not sure how I implement this in a controller/view. Can someone
> explain how I can implement a facet where at the top of my search
> results I have a field that basically looks like this...
>
> Service Address (3)
>
> The 3 would represent the number of search results returned for the
> "s_service_address" field. If a user clicks on "Service Address (3)"
> the search results would then get filtered. Any help in the right
> direction would be appreciated. To view my model/controller/view info,
> you can use the example I posted on my blog. This is my current setup.
>
> http://railstrip.ourgreatjourney.com/rails_thinkingsphinx_2_models/
>
> I started using my blog as an online diary of my troubles/solutions,
> so if I get this figured out I will be sure to add a new post on how
> to do it.
>
> Thanks!
>
> Chris
>
> >


--~--~---------~--~----~------------~-------~--~----~
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