【发布时间】:2015-07-20 06:14:01
【问题描述】:
我在 Rails 中使用 Sunspot Solr。我的代码如下所示:
searchable do
text :title, :stored => true
string :id, :stored => true
integer :status, :stored => true
end
在我的控制器中,执行搜索后,我将其存储在哈希中:
one_result= {:title => hit.stored(:title), :id => hit.stored(:id)}
现在当我执行puts one_result.inspect 时,我得到:
{"title": ["THIS IS TITLE"]
"id":12345
}
问题是所有的文本字段都变成了数组[..]。我想将结果包含在 json 响应中。我希望它是:
{"title": "THIS IS TITLE"
"id":12345
}
有什么帮助吗?
【问题讨论】:
标签: ruby-on-rails solr sunspot-solr