Thinking Sphinx: Failed index on double precision field
Trying to add an index to a field containing a ruby float (represented as double precision in Postgres), I get the following error when rebuilding the index:
indexing index 'user_core'...
ERROR: index 'user_core': sql_range_query: ERROR: invalid input syntax for type double precis开发者_开发技巧ion: ""
LINE 1: ..._name_sort", COALESCE("users"."average_rating", '') AS "av...
The line I added in the model that caused this error to appear is as follows:
indexes :average_rating, :sortable => true, :type => :float
Been unable to find anyone having trouble indexing floats by googling. Is this a bug, or am I missing something obvious as usual? :)
This is probably because it is not a string based column, try this:
has :average_rating, :sortable => true, :type => :float
To read more about the differences between "has" and "indexes" read this: http://freelancing-god.github.com/ts/en/sphinx_basics.html
精彩评论