我有一个嵌套字段形式为的 solr 索引
{ record: [
{ tag1: foo, tag2: bar }
]
}
遗憾的是,solr 配置无法更改。
在 Blacklight 中,我想在不同的字段下分别显示foo
和显示,如下所示:bar
Tag1: foo
Tag2: bar
我在想我可以使用 config.add_index_field 和辅助方法来实现这一点:
catalog_controller.rb
config.add_index_field 'record', label: 'Tag1', helper_method: :get_tag1
config.add_index_field 'record', label: 'Tag2', helper_method: :get_tag2
application_helper.rb
def get_tag1(options={})
options[:value][0]['tag1']
end
def get_tag2(options={})
options[:value][0]['tag2']
end
但是,这样做时我收到错误A index_field with the key record already exists.
显然,我一次只能为每个 solr 字段添加一个索引字段。如何在 Blacklight 中将一个这样的字段变成多个字段?