I seem to be unable to filter on associated, string, attributes using
postgres:
class CompetitorPage < ActiveRecord::Base
belongs_to :state
define_index do
indexes :name, :sortable => true
join state
has "CRC32(states.abbreviation)", :as => 'state_name', :type => :string
group_by "states.abbreviation"
set_property :delta => :datetime, :threshold => 3.minutes
end
end
Getting this from ts:rebuild
01: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 do
indexes :name, :sortable => true
join state
has "CAST(CRC32(states.abbreviation) AS text)", :as => 'state_name',
:type => :string
group_by "states.abbreviation"
set_property :delta => :datetime, :threshold => 3.minutes
end
And 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
=> 3
What'd I miss?
--
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/-/0YAu-IAJTtYJ.
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.