0

次の形式のネストされたフィールドを持つsolrインデックスがあります

{ record: [
    { tag1: foo, tag2: bar }
  ]
}

残念ながら、solr の設定は変更できません。

ブラックライトでは、次のように異なるフィールドの下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 フィールドごとに一度に 1 つのインデックス フィールドしか追加できないようです。そのようなフィールドを Blacklight で複数のフィールドに変換するにはどうすればよいですか?

4

1 に答える 1