开发者

Thinking Sphinx: Failed index on double precision field

开发者 https://www.devze.com 2023-04-05 16:23 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号