SearchElasticsearch 2025.10.2.19

捆绑包

org.apache.nifi | nifi-elasticsearch-restapi-nar

描述

一种允许用户重复运行使用 Elasticsearch JSON DSL 编写的分页查询(包含聚合)的处理器。Search After/Point in Time 查询必须包含有效的“sort”字段。该处理器将检索多页结果,直到没有更多结果可用或 Pagination Keep Alive 期限到期为止,此后查询将重新开始,再次检索第一页结果。

标签

elasticsearch, elasticsearch7, elasticsearch8, elasticsearch9, json, page, query, scroll, search

输入要求

FORBIDDEN

支持敏感的动态属性

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-pagination-keep-alive

分页“keep_alive”时间段。Elasticsearch 将在请求之间保持滚动/pit 游标存活的时间段(此时间并非预期返回所有页面的总时长,而是两次分页检索请求之间允许的最大间隔时间)。

el-rest-pagination-type

要使用的分页方法。并非所有 Elasticsearch 版本都支持所有类型,请查看 Elasticsearch 文档以确认哪些适用于您的服务并推荐使用。

el-rest-query

JSON 语法(而非 Lucene 语法)中的查询。例如:{"query":{"match":{"somefield":"somevalue"}}}。如果查询为空,则将使用默认 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

查询中要检索的最大文档数。如果查询是分页的,则此“大小”是应用查询的每个页面,而不是整个结果集的“大小”。

restart-on-finish

是否应在分页搜索完成后,处理器使用相同的查询开始另一次搜索。

状态管理

范围

描述

LOCAL

分页状态(scrollId、searchAfter、pitId、hitCount、pageCount、pageExpirationTimestamp)在此处理器的调用之间保留,直到 Scroll/PiT 到期(当前时间晚于上次执行查询的时间加上“Pagination Keep Alive”时间间隔)。

关系

名称

描述

aggregations

聚合将路由到此关系。

failure

所有因与服务器可用性无关的原因而失败的 FlowFile 都将转到此关系。

hits

搜索命中将路由到此关系。

retry

所有因服务器/集群可用性而失败的 FlowFile 都将转到此关系。

写入属性

名称

描述

mime.type

application/json

aggregation.name

其结果在输出 FlowFile 中的聚合名称

aggregation.number

其结果在输出 FlowFile 中的聚合编号

page.number

返回结果的页面(请求)编号,从 1 开始,包含在输出 FlowFile 中。

hit.count

包含在输出 FlowFile 中的命中次数

elasticsearch.query.error

当查询索引出现错误时由 Elasticsearch 提供的错误消息。

另请参阅

语言: 中文