107.7. 使用方法
107.7.1. 消息操作 复制链接链接已复制到粘贴板!
目前支持以下 OpenSearch 操作。设置端点 URI 选项或交换标头,其键为"operation",值设为以下之一:有些操作还需要设置其他参数或消息正文。
| operation | 消息正文 | description |
|---|---|---|
|
|
将 , | 将内容添加到索引中,并在正文中返回内容的 indexId。您可以通过使用键 "indexName" 设置消息标头来设置目标索引的名称。您可以使用键 "indexId" 设置消息标头来设置 indexId。 |
|
|
要检索的内容的字符串或 | 检索与给定索引 id 对应的文档,并返回正文中的 GetResponse 对象。您可以通过使用键 "indexName" 设置消息标头来设置目标索引的名称。您可以使用键 "documentClass" 设置消息标头来设置文档类型。 |
|
|
要删除的内容的字符串或 | 删除指定的 indexName,并在正文中返回一个 Result 对象。您可以通过使用键 "indexName" 设置消息标头来设置目标索引的名称。 |
|
|
要删除的索引的字符串或 | 删除指定的 indexName,并返回正文中的状态代码。您可以通过使用键 "indexName" 设置消息标头来设置目标索引的名称。 |
|
任何已接受的任何类型的 | 从索引中添加/更新/删除内容,并返回正文中的 List<BulkResponseItem> 对象,您可以通过使用键 "indexName" 设置消息标头来设置目标索引的名称。 |
|
|
| 使用查询字符串映射搜索内容。您可以通过使用键 "indexName" 设置消息标头来设置目标索引的名称。您可以通过使用键 "size" 设置 message 标头来设置要返回的 hits 数。您可以使用键"from"设置消息标头来设置启动文档偏移。 |
|
|
| 一个中的多个搜索 |
|
|
| 在一个里有多个 您可以通过使用键 "indexName" 设置消息标头来设置目标索引的名称。 |
|
| None | 检查索引是否存在,并返回正文中的布尔值标志。 您必须通过设置带有键 "indexName" 的 message 标头来设置目标索引的名称。 |
|
|
| 将内容更新为索引,并返回正文中内容的 indexId。您可以通过使用键 "indexName" 设置消息标头来设置目标索引的名称。您可以使用键 "indexId" 设置消息标头来设置 indexId。 | ping |
107.7.2. 配置组件并启用基本身份验证 复制链接链接已复制到粘贴板!
要使用 OpenSearch 组件,必须使用最小配置进行配置。
OpensearchComponent opensearchComponent = new OpensearchComponent();
opensearchComponent.setHostAddresses("opensearch-host:9200");
camelContext.addComponent("opensearch", opensearchComponent);
OpensearchComponent opensearchComponent = new OpensearchComponent();
opensearchComponent.setHostAddresses("opensearch-host:9200");
camelContext.addComponent("opensearch", opensearchComponent);
对于使用 OpenSearch 的基本身份验证或使用 OpenSearch 集群前面的反向代理,只需在组件上设置基本身份验证和 SSL,如下例所示
107.7.3. 文档类型 复制链接链接已复制到粘贴板!
对于所有搜索操作,可以指示要检索的文档类型,以获得带有预期类型的结果。
可以使用标头 "documentClass" 或相同名称的 uri 参数来设置文档类型。