我有一个包含嵌套字段的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_tag2application_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中将一个这样的字段转换为多个字段?
发布于 2019-10-23 19:09:49
找到答案了。我只需要添加字段变量来指向相同的标记,这样我就可以更改原始变量。
catalog_controller.rb
config.add_index_field 'record1', label: 'Tag1', field: 'record', helper_method: :get_tag1
config.add_index_field 'record2', label: 'Tag2', field: 'record', helper_method: :get_tag2https://stackoverflow.com/questions/58521154
复制相似问题