I have a solr index with nested fields in the form of
{ record: [
{ tag1: foo, tag2: bar }
]
}
The solr configuration cannot be changed, unfortunately.
In Blacklight, I want to display foo and bar separately under different fields, like so:
Tag1: foo
Tag2: bar
I was thinking I could just use config.add_index_field with a helper method to achieve this:
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
However, when doing so I get the error A index_field with the key record already exists.
Apparently, I can only add one index field per solr field at a time. How can I turn one such field into multiple fields in Blacklight?
Found the answer. I simply need to add the field variable to point to the same tag, that way I can change the original variable.