I seem to be unable to filter on associated, string, attributes using postgres:class CompetitorPage < ActiveRecord::Basebelongs_to :statedefine_index doindexes :name, :sortable => truejoin statehas "CRC32(states.abbreviation)", :as => 'state_name', :type => :stringgroup_by "states.abbreviation"set_property :delta => :datetime, :threshold => 3.minutesendendGetting this from ts:rebuild01:49:16 sphinx.1 | ERROR: index 'competitor_page_core': sql_range_query: ERROR: invalid input syntax for integer: ""01:49:16 sphinx.1 | LINE 1: ..."name_sort", COALESCE(CRC32(states.abbreviation), '') AS "st...... which is postgres chocking out on the mixed data types being feed to COALESCE (CRC(...) being an integer and '' being a string)So I changed my index to be this:define_index doindexes :name, :sortable => truejoin statehas "CAST(CRC32(states.abbreviation) AS text)", :as => 'state_name', :type => :stringgroup_by "states.abbreviation"set_property :delta => :datetime, :threshold => 3.minutesendAnd that allows ts:rebuild to complete, but then i can't search on state_name:?> CompetitorPage.search(:with => {'state_name' => "NY"})Sphinx Query (3.0ms)Sphinx Found 0 results=> []And they do exist:>> CompetitorPage.all.map{|c| c.state.abbreviation}.group_by{|a| a}["NY"].length=> 3What'd I miss?
You'll need to change a couple of things. Firstly, the attribute type is an integer - the CRC32'd value of the city (in your second example). And secondly, you'll need to filter by the CRC32'd value itself. So:
has "CRC32(city)", :as => :city, :type => :integer
And then:
Model.search :with => {:city => 'Melbourne'.to_crc32}
That should do the trick.
--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/8QWwKNB0H00J.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.