jdbc-river を使用して、PostgreSQL データベースから Elasticsearch インスタンスを埋めます。リバーのレコードは、次の Ruby のコードで作成されます (Rails アプリから ES をクエリするため)。
require 'elasticsearch'
client = Elasticsearch::Client.new
client.create :index => "_river", :type => "ldi", :id => "_meta", :body =>
{
:type => :jdbc,
:jdbc => {
:driver => "org.postgresql.Driver",
:url => "jdbc:postgresql://localhost:5432/" + ENV['DB_NAME'],
:user => ENV['DB_USER'],
:password => ENV['DB_PASS'],
:index => ENV['DB_NAME'],
:type => "ldi",
:sql => "select id as _id, * from ldis"
}
}
データベース資格情報に環境変数を使用して、実際の資格情報を表示しないようにしています。問題は、レコードが ES に追加されると、実際の資格情報が公開されることです。したがって、ES にクエリを実行して、次のようなものを取得できます。
"hits": {
"total": 6,
"max_score": 1,
"hits": [
{
"_index": "_river",
"_type": "ldi",
"_id": "_meta",
"_score": 1,
"_source": {
"type": "jdbc",
"jdbc": {
"driver": "org.postgresql.Driver",
"url": "jdbc:postgresql://localhost:5432/any_dbname",
"user": "any_dbuser",
"password": "any_dbpass",
"index": "any_index",
"type": "ldi",
"sql": "select id as _id, * from ldis"
}
}
}
....
それらを秘密にしておく方法はありますか?