Oh man, I owe you one! Thank you so much - this works just great. 

On Friday, April 5, 2013 4:01:30 AM UTC+1, Pat Allan wrote:
>
> Hi Alex
>
> It's worth noting that facets calls, like search calls, don't 
> automatically populate until you're accessing search results. This would be 
> why the returned object is the same whether or not Sphinx is running.
>
> If you access facet values in that object, it'll run the appropriate query 
> and provide facet results:
>
>   User.facets[:full_name]
>
> Let me know if that helps clear everything up.
>
> Cheers
>
> -- 
> Pat
>
> On 05/04/2013, at 1:58 AM, [email protected] <javascript:> wrote:
>
> > upon further investigation User.facets returns the same data even when 
> searchd is stopped. How could it work if it isn't even making a connection 
> to sphinx? Is this a bug or am I doing something stupid?
> > 
> > 
> > 
> > On Thursday, April 4, 2013 10:05:22 AM UTC+1, [email protected] wrote:
> > Hi
> > 
> > I've been trying to get this going now for 2 days and have trawled thru 
> lots and lots of resources online. I simply cannot get facets working! Can 
> someone tell me where I'm going wrong? The documentation on the TS site 
> mentions the details on facets has yet to be updated for TS3 but from what 
> I can see not much has changed at least with the syntax on how you declare 
> facets within the indices.
> > 
> > My bundle contains:
> > 
> > Using mysql2 (0.3.12b4) 
> > Using rails (3.2.13) 
> > Using thinking-sphinx (3.0.2) 
> > 
> > A simple user model (as a test) :
> > 
> > class User < ActiveRecord::Base
> >   has_many :user_managers
> >   attr_accessible :email, :full_name
> >   accepts_nested_attributes_for :user_managers
> > end
> > 
> > I have created 4 users as a test:
> > 
> > irb(main):004:0> User.all.map(&:full_name)
> >   User Load (0.2ms)  SELECT `users`.* FROM `users` 
> > => ["James Watson", "James Smith", "James Shannon", "James Waldron"]
> > 
> > my Indices for the user model:
> > 
> > ThinkingSphinx::Index.define :user, :with => :active_record do
> >   indexes full_name, :as => :full_name, :facet => true
> >   has created_at, :facet => true
> >   has id, :facet => true
> > end
> > 
> > and rebuilt the indices:
> > 
> > jbw@cygnus /tmp/testical » rake ts:rebuild                               
>                                                                             
>  20 ↵
> > Stopped searchd daemon (pid: 17395).
> > Generating configuration to /tmp/test/config/development.sphinx.conf
> > Sphinx 2.0.7-id64-release (r3759)
> > Copyright (c) 2001-2012, Andrew Aksyonoff
> > Copyright (c) 2008-2012, Sphinx Technologies Inc (
> http://sphinxsearch.com)
> > 
> > using config file '/tmp/testical/config/development.sphinx.conf'...
> > indexing index 'user_core'...
> > collected 4 docs, 0.0 MB
> > sorted 0.0 Mhits, 100.0% done
> > total 4 docs, 65 bytes
> > total 0.049 sec, 1307 bytes/sec, 80.45 docs/sec
> > total 3 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
> > total 9 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
> > Started searchd successfully (pid: 20433).
> > 
> > Searching works fine:
> > 
> > irb(main):009:0> User.search("James").map(&:full_name)
> >   User Load (0.1ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` IN 
> (7, 8, 9, 10)
> > => ["James Watson", "James Smith", "James Shannon", "James Waldron"]
> > 
> > But facets just gets returned as empty:
> > 
> > irb(main):010:0> User.facets
> > => #<ThinkingSphinx::FacetSearch:0x00000003957b28 
> @options={:classes=>[User(id: integer, full_name: string, email: string, 
> created_at: datetime, updated_at: datetime)]}, @query=nil, @hash={}>
> > 
> > 
> > I cannot for the life of my figure out why it's not working. What am I 
> doing wrong?
> > 
> > Thanks in advance
> > AlexB
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Thinking Sphinx" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>.
> > To post to this group, send email to 
> > [email protected]<javascript:>
> .
> > Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en
> .
> > For more options, visit https://groups.google.com/groups/opt_out.
> >  
> >  
>
>
>

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


Reply via email to