The issue here is that you need to use tables/columns in SQL snippets. You'll also want to refer to the join to ensure it's loaded, and perhaps will need to add the column to the generated GROUP BY clause as well:
has "YEAR(artifacts.released)", :as => :release_year, :type => :integer join user_item.artifact group_by "YEAR(artifacts.released)" (all of the above goes in the index definition) On 1 Apr 2014, at 4:21 am, J. Garcia <[email protected]> wrote: > Hi, > I am trying to create an index with an attribute based on the YEAR() function > on a Rails date field. > > Something similar to this: > > ThinkingSphinx::Index.define :list_item, :with => :active_record do > has user_item.artifact_id > has "YEAR(user_item.artifact.released)", :as => :release_year, :type => > :integer > end > > However, I am getting this error: > > indexing index 'list_item_core'... > ERROR: index 'list_item_core': sql_range_query: Unknown column > 'user_item.artifact.released' in 'field list' > (DSN=mysql://username:***@127.0.0.1:3306/my_database_dev). > > If I use > > has user_item.artifact.released > > it works well, but I need the precalculated year to do grouping or faceting. > > Any tip on what am I doing wrong? > > > -- > 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. -- 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.
