I think switching to an attribute (using the `has` method) will result in 
better facet results:

  has visits.visit_year, :as => :visited, :facet => true

It’s worth noting that the :type option has no impact on fields, and for 
attributes, there are two separate options, :type (which in this case would be 
:integer) and :multi (accepting a boolean). Given it’s a has_many attribute, 
:multi will automatically be set to true, and if the visit_year column in your 
database is an integer type, then that’ll automatically be detected by Thinking 
Sphinx as well.

If you want users to be able to search for the year within their queries as 
well, then you’ll want a field *as well* - just make sure the field and the 
attribute don’t have the same name.

  indexes visits.visit_year, :as => :visit_year
  has visits.visit_year, :as => :visited, :facet => true

Kind regards,

— 
Pat

> On 16 Oct 2015, at 9:37 am, Anrake <[email protected]> wrote:
> 
> When I index a field via a has_many relationship the facets that come out are 
> a joined facet of all the values.  
> 
> In the index I have this
> 
>       indexes visits.visit_year, :type => :multi, :as => :visited, :facet => 
> true
> 
> but the facets that come through look like this instead of individual values 
> for each year
> 
> 1996 1997 1998 2004 2009 2012 (1)
> 2001 (4)
> 1999 2009 2010 (1)
> 1992 2001 2003 2004 2011 2012 2013 2014 2015 (1)
> 
> This is a database of historical sites and the has_many for visits are the 
> years we surveyed them. 
> 
> details:
> ruby 2.2
> rails 4.2
> thinking_sphing: 3.1.4
> 
> Thank you.
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/thinking-sphinx 
> <http://groups.google.com/group/thinking-sphinx>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to