sunspot-solr 中的结果格式
format of result in sunspot-solr
我在 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
}
有什么帮助吗?
我猜 "Title" 字段的 fieldType 在 schema.xml.
中定义为多值="true"
请将其设置为 false,以便将其作为字符串获取。
我在 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
}
有什么帮助吗?
我猜 "Title" 字段的 fieldType 在 schema.xml.
中定义为多值="true"请将其设置为 false,以便将其作为字符串获取。