Geo*_*old 2 ruby lucene solr sunspot sunspot-solr
我正在尝试在我的模型中添加一个时间戳字段,以便通过Sunspot/Solr进行索引.Solr对此产生了扼要并产生了NumberFormatException:
class Book < ActiveRecord::Base
attr_accessible :lastUpdated, :category, :title # etc...
searchable do
text :title
text :category
time :lastUpdated # mysql 'datetime' field
# etc...
end
end
Jun 06, 2012 10:59:10 AM org.apache.solr.common.SolrException log
SEVERE: java.lang.NumberFormatException: For input string: "2012-01-02T03:29:00Z"
Run Code Online (Sandbox Code Playgroud)
我也试过使用date :lastUpdated相同的结果.
想到我的模型可能有一些虚假的lastUpdated价值,我试着将结果编入索引Time.now,并得到相同的结果.
我在外部使用Solr 3.4.0,但使用提供的"内部"Solr重现了同样的问题sunspot-installer,并相应地进行了调整sunspot.yml.我的情况似乎很像这里提到的问题,但重新安装Sunspot/Solr配置似乎并没有解决它.
编辑:还试过反对Solr 3.6.0; 同样的结果.
Geo*_*old 11
我怀疑这是由于Sunspot的type.rb中的一个错误.TimeType将其定义indexed_name为"_d",而不是"_dt".我在我的模型代码中使用以下方法解决了这个问题:
module Sunspot
module Type
class TimeType < AbstractType
def indexed_name(name) #:nodoc:
"#{name}_dt"
end
end
register TimeType
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
699 次 |
| 最近记录: |