Apache Camel在Elasticsearch连接器中指定_id

问题描述 投票:1回答:1

我正在使用弹性支撑部件https://camel.apache.org/components/latest/elasticsearch-rest-component.html我无法以任何方式指定文档的ID。从这个意义上说,文档似乎很缺乏

代码或多或少像

from(RAW_ROUTE)
            .process(new RawProcessor())
            .to("elasticsearch://local?operation=Index&indexName=raw&indexType=_doc")
    ;

RawProcessor将Map设置为交换对象的主体

非常感谢

elasticsearch apache-camel
1个回答
0
投票

[_id可以用indexId标头设置。

请参见Message Operations

索引:将内容添加到索引,并在正文中返回内容的indexId。您可以通过使用键“ indexId”]设置消息头来设置indexId

您可以在单元测试ElasticsearchIndexTest#testIndexWithIDInHeader中找到示例用法。

© www.soinside.com 2019 - 2024. All rights reserved.