SOLR DIH にこのコードを使用しています。
<dataConfig>
<dataSource name="app" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/wikipedia" user="wikipedia" password="secret" />
<dataSource name="data" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/wikipedia" user="wikipedia" password="secret" />
<document>
<entity dataSource="app-ds" name="item" query="SELECT id, title, description, date, link, location_id, source_id, company_id from item">
<field column="id" name="id" />
<field column="title" name="title" />
<field column="description" name="description" />
<field column="date" name="date" />
<field column="link" name="link" />
<entity dataSource="app-ds" name="location" query="SELECT name, coordinate from location where location_id=${item.location_id}">
<field column="name" name="location_name" />
<field column="coordinate" name="location_coordinates" />
</entity>
<entity dataSource="app-ds" name="source" query="SELECT name from source where source_id=${item.source_id}">
<field column="name" name="source_name" />
</entity>
<entity dataSource="app-ds" name="company" query="SELECT name from company where company_id=${item.company_id}">
<field column="name" name="company_name" />
</entity>
</entity>
</document>
</dataConfig>
2 つのデータベースをマージしているので、SOLR 内の各エントリに一意の ID が必要です。私の場合、これを行う最善の方法は、最初のデータベース ID に app* ID * を、2 番目のデータベース ID に data* ID * を使用することです。
上記のコードを使用して、SOLR ID フィールドに格納されている ID の前に「アプリ」という単語を追加して、データベース ID=123 および Solr ID = app123 にする方法を教えてください。
編集:私が推測するように、それはこのようなものかもしれません(しかし、私はSQLが得意ではありません)
query="SELECT app_(id)