JavaプログラムのElastic SearchのデータをTranportClientクラスで更新しようとしています。私は、このようにUPDATEすることができます知っている:ivarId、チャンネルとはをbacId:3つのフィールドが含まれて私のユーザー定義クラスであるTransferClientを使用してJavaでElasticSearchに保存されたデータを更新する
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.field("source.ivarId", source.ivarId)
.field("source.channel", source.channel)
.field("source.bacId", source.bacId).endObject();
UpdateResponse response = client.prepareUpdate(_index, _type, _id).setDoc(builder.string()).get();
ソースながら。
しかし、私が知りたいのと同じことを行うことができます任意の方法があるが、私は内側に各フィールドを割り当てる必要がないように、別の効率的より簡単に方法を使用してクラス?たとえば、私はこれを行うことはできますか?
XContentBuilder builder = XContentFactory.jsonBuilder().startObject()
.field("source", source).endObject();
UpdateResponse response = client.prepareUpdate(_index, _type, _id).setDoc(builder.string()).get();
私は後者の方法を試みたが、私はこの例外だ:私はのJava 1.8.0.121を使用していて、ElasticSearchとのtransportClientの両方のバージョンがある
MapperParsingException[object mapping for [source] tried to parse field [source] as object, but found a concrete value]
を5.1。ありがとう!