JsonQueryElasticsearch 2025.10.2.19¶
捆绑包¶
org.apache.nifi | nifi-elasticsearch-restapi-nar
描述¶
一种允许用户运行使用 Elasticsearch JSON DSL 编写的查询(包含聚合)的处理器。它不会自动为用户对查询进行分页。如果向该处理器添加了传入关系,它将使用 FlowFile 的内容进行查询。需特别注意查询数据量的大小,因为 Elasticsearch 的整个响应会一次性加载到内存中,并转换为最终的 FlowFile。
输入要求¶
ALLOWED
支持敏感的动态属性¶
false
属性¶
| 属性 | 描述 | 
|---|---|
| 最大 JSON 字段字符串长度 | 解析 JSON 文档或属性时字符串值的最大允许长度。 | 
| el-query-attribute | 如果设置此参数,系统将在每个结果 FlowFile 的指定属性中记录所执行的查询。 | 
| el-rest-client-service | 用于运行查询的 Elasticsearch 客户端服务。 | 
| el-rest-fetch-index | 要使用的索引的名称。 | 
| el-rest-format-aggregations | 聚合输出的格式。 | 
| el-rest-format-hits | Hits 输出格式。 | 
| el-rest-output-no-hits | 即使没有找到查询的“hits”,也要输出“hits”FlowFile。如果为 true,则即使输出“aggregations”,也会输出一个空的“hits”FlowFile。 | 
| el-rest-query | JSON 语法(而非 Lucene 语法)中的查询。例如:{"query":{"match":{"somefield":"somevalue"}}}。如果未设置此参数,则将从 FlowFile 内容中读取查询。如果查询(属性和 FlowFile 内容)为空,则将使用默认的空 JSON 对象,这将导致 Elasticsearch 中出现“match_all”查询。 | 
| el-rest-query-clause | JSON 语法(而非 Lucene 语法)中的“query”子句。例如:{"match":{"somefield":"somevalue"}}。如果查询为空,则将使用默认 JSON 对象,这将导致 Elasticsearch 中出现“match_all”查询。 | 
| el-rest-query-definition-style | 如何定义 JSON 查询以供处理器使用。 | 
| el-rest-split-up-aggregations | 输出一个包含所有聚合的 FlowFile,或者为每个单独的聚合输出一个 FlowFile。 | 
| el-rest-split-up-hits | 输出一个包含所有命中的 FlowFile,或者为每个单独的命中输出一个 FlowFile。 | 
| el-rest-type | 此文档的类型(由 Elasticsearch 用于建立索引和执行搜索)。 | 
| es-rest-query-aggs | 一个或多个查询聚合(或“aggs”),采用 JSON 语法。例如:{"items": {"terms": {"field": "product", "size":10}}} | 
| es-rest-query-fields | 要检索的已编制索引的文档的字段,采用 JSON 语法。例如:["user.id", "http.response.*", {"field": "@timestamp", "format": "epoch_millis"}] | 
| es-rest-query-script-fields | Fields to created using script evaluation at query runtime, in JSON syntax. Ex: {"test1": {"script": {"lang": "painless", "source": "doc[ 'price'].value * 2"}}, "test2": {"script": {"lang": "painless", "source": "doc[ 'price'].value * params.factor", "params": {"factor": 2.0}}}} | 
| es-rest-query-sort | 按一个或多个字段对结果进行排序,采用 JSON 语法。例如:[{"price" : {"order" : "asc", "mode" : "avg"}}, {"post_date" : {"format": "strict_date_optional_time_nanos"}}] | 
| es-rest-size | 查询中要检索的最大文档数。如果查询是分页的,则此“大小”是应用查询的每个页面,而不是整个结果集的“大小”。 | 
关系¶
| 名称 | 描述 | 
|---|---|
| aggregations | 聚合将路由到此关系。 | 
| failure | 所有因与服务器可用性无关的原因而失败的 FlowFile 都将转到此关系。 | 
| hits | 搜索命中将路由到此关系。 | 
| original | 所有不会导致出错的原始 FlowFile 都转到此关系。 | 
写入属性¶
| 名称 | 描述 | 
|---|---|
| mime.type | application/json | 
| aggregation.name | 其结果在输出 FlowFile 中的聚合名称 | 
| aggregation.number | 其结果在输出 FlowFile 中的聚合编号 | 
| hit.count | 包含在输出 FlowFile 中的命中次数 | 
| elasticsearch.query.error | 当查询索引出现错误时由 Elasticsearch 提供的错误消息。 |