Elasticsearch:Jina Reader

从网页和文档中提取可用文本比看起来更具挑战性。HTML 页面将有意义的内容与布局元素、脚本、广告和样式规则混合在一起,而 PDF 文件则围绕打印逻辑进行结构化,而非自然的文本流。如果没有可靠的方法来解析这些格式,即使是简单的提取也可能变得不一致且难以自动化。

Reader 通过像浏览器一样精确渲染源内容,然后从完全解析后的文档中提取文本来解决这个问题。这种方法避免了猜测,并能在各种真实世界的网站和文件中生成稳定的输出。

Jina Reader 服务提供两个 endpoints,分别提供不同的服务:

  • r.jina.ai :通过 r.jina.ai/ 将任何 URL 转换为 LLM-ready text,为你的 agents 和 RAG 系统生成更干净、更可靠的输入。

  • s.jina.ai :通过 s.jina.ai/your+query 对任意查询执行实时 web search,使你的 LLMs 能够从整个 web 获取最新信息。

这两个 endpoints 结合在一起,为开发者提供了一种简单、可靠的方式,只需一次请求,就能将复杂的 HTML 或 PDF 源转换为干净的 Markdown 或结构良好的 JSON,使 Reader 成为任何数据摄取或处理 pipeline 的实用基础。

快速开始

为了快速了解 Reader,你可以直接使用任何 internet browser,而无需编写任何代码或配置 API key。

HTML → Markdown

打开 www.elastic.co/elasticsear... 。你应该会看到 Elasticsearch 产品页面(截图截至 2025 年 11 月 17 日)。

现在通过 Reader 打开同一个页面,只需在 URL 前加上 r.jina.ai:

r.jina.ai/https://www...

Reader 会返回一个以 Markdown 格式表示页面内容的纯文本响应。

通过 r.jina.ai 在浏览器中直接访问 Reader 是一种方便的实验方式。免费、未认证的使用是有速率限制的,并且对某些 URL 可能会受到限制。对于生产环境或更高优先级的工作流,你应该使用带 API key 的认证 API。你可以在 Jina Reader API 网站获取一个 API key,并在下一节所示的请求头中插入它。

使用 Reader

将页面转换为 Markdown

使用 Reader 的最简单方式是将一个 URL 传给 r.jina.ai/ 并使用任何可访问互联网的工具保存输出。

使用 curl:

markdown 复制代码
`

1.  curl "https://r.jina.ai/https://www.elastic.co/elasticsearch" \
2.     -o elasticsearch.md

`AI写代码

这里,标志和参数 -o elasticsearch.md 会把结果写入一个名为 elasticsearch.md 的本地文件。

使用 wget:

markdown 复制代码
`

1.  wget \
2.    --header="X-Return-Format: markdown" \
3.    -O elasticsearch.md \
4.    "https://r.jina.ai/https://www.elastic.co/elasticsearch"

`AI写代码

参数 -O elasticsearch.md 会把结果写入指定的文件。

使用 Python:

markdown 复制代码
`

1.  import requests

3.  headers = {
4.      "X-Return-Format": "markdown",
5.  }

7.  response = requests.get(
8.      "https://r.jina.ai/https://www.elastic.co/elasticsearch",
9.      headers=headers,
10.  )
11.  print(response.text)

`AI写代码![](https://csdnimg.cn/release/blogv2/dist/pc/img/runCode/icon-arrowwhite.png)

这段代码会把结果打印到屏幕上。

我们还提供一个交互式界面,让你可以尝试不同的参数设置,并自动生成其他编程语言的示例代码。

认证使用和输出模式

如果你需要更高优先级的访问和更少的限制,请在 Authorization header 中包含你的 Jina API key(将下面示例中的 YOUR_API_KEY 替换为你的 key),并且可以通过 X-Return-Format 可选地指定明确的输出模式。

使用 curl:

markdown 复制代码
`

1.  curl "https://r.jina.ai/https://www.elastic.co/elasticsearch" \
2.    -H "Authorization: Bearer YOUR_API_KEY" \
3.    -H "X-Return-Format: markdown" \
4.    -o elasticsearch.md

`AI写代码

使用 wget:

ini 复制代码
`

1.  wget \
2.    --header="Authorization: Bearer YOUR_API_KEY" \
3.    --header="X-Return-Format: markdown" \
4.    -O elasticsearch.md \
5.    "https://r.jina.ai/https://www.elastic.co/elasticsearch"

`AI写代码

使用 Python:

markdown 复制代码
`

1.  import requests

3.  headers = {
4.      "Authorization": "Bearer YOUR_API_KEY",
5.      "X-Return-Format": "markdown",
6.  }

8.  response = requests.get(
9.      "https://r.jina.ai/https://www.elastic.co/elasticsearch",
10.      headers=headers,
11.  )
12.  print(response.text)

`AI写代码![](https://csdnimg.cn/release/blogv2/dist/pc/img/runCode/icon-arrowwhite.png)

JSON 模式

在生产环境中,你可能更希望将 Reader 的输出包装成一个 JSON 对象,这样更容易解析。要在 r.jina.ai 上启用 JSON 模式,请添加请求头 Accept: application/json。例如,在 Python 中:

json 复制代码
`

1.  headers = {
2.      "Authorization": "Bearer <YOUR_API_KEY>",
3.      "X-Return-Format": "markdown",
4.      "Accept": "application/json",
5.  }

`AI写代码

对于 curl,使用标志 -H "Authorization: Bearer <YOUR_API_KEY>";对于 wget,使用 --header="Authorization: Bearer <YOUR_API_KEY>",如上例所示,将 header 添加到请求中。生成的 JSON 输出核心部分如下所示:

bash 复制代码
`

1.  {
2.    "code": 200,
3.    "status": 20000,
4.    "data": {
5.      "title": "...",
6.      "description": "...",
7.      "url": "https://www.elastic.co/elasticsearch",
8.      "content": "..."   
9.    }
10.  }

`AI写代码![](https://csdnimg.cn/release/blogv2/dist/pc/img/runCode/icon-arrowwhite.png)

有关通过 r.jina.ai 提供的服务的更多信息,请访问 Reader API 文档页面。

使用 s.jina.ai 搜索

Reader ------ 通过 s.jina.ai API ------ 执行 web search:你提供一个 query,它会处理来自搜索引擎的结果。它提供的服务是标准化 SERPs(Search Engine Results Page):即你在 Google 或其他搜索引擎搜索时得到的结果页面。SERP 通常包含一组带有 snippets、预览文本和小型 metadata 字段的链接,但直接提取很困难,因为页面通常还包含广告以及可选服务或其他产品的链接。

使用方法很简单,只需检索以下 URL,并替换为你自己的查询词:

arduino 复制代码
`https://s.jina.ai/<your search query>`AI写代码

将查询词之间的空格替换为 "+",如下面的示例所示:

arduino 复制代码
`https://s.jina.ai/Elastic+Jina+AI`AI写代码

Reader API 会在 Google 上执行你的搜索,并将结果处理成结构化的 Markdown 页面,其中包含前 10 个匹配项的页面标题、URL,以及底层搜索引擎提供的描述/摘要。默认情况下,它还会尝试抓取网页并将其转换为 Markdown,使用与上述 HTML/PDF 转 Markdown 转换器相同的模型,但请求可能因超时或其他原因失败,因此页面可能不存在。

与所有 Reader API 服务一样,如果你使用 Jina API key,你将获得更高优先级,因此可以更快地获得结果,无流量限制,也不会因流量过大而被拒绝请求。

一个具体示例:

arduino 复制代码
`curl "https://s.jina.ai/Elastic+Jina" -H "Authorization: Bearer <YOUR_API_KEY>"`AI写代码

这会返回 Markdown 格式的文本,看起来如下:

sql 复制代码
`

1.  [1] Title: Elastic and Jina AI join forces to advance open source retrieval for AI ...
2.  [1] URL Source: https://www.elastic.co/blog/elastic-jina-ai
3.  [1] Description: We are thrilled to announce that Elastic has joined forces with Jina AI, a pioneer in open source multimodal and multilingual embeddings, ...
4.  [1] Date: Oct 9, 2025

7.  [2] Title: Elastic Completes Acquisition of Jina AI, a Leader in Frontier Models for Multimodal and Multilingual Search
8.  [2] URL Source: https://ir.elastic.co/news/news-details/2025/Elastic-Completes-Acquisition-of-Jina-AI-a-Leader-in-Frontier-Models-for-Multimodal-and-Multilingual-Search/default.aspx
9.  [2] Description: Acquisition advances Elastic's leadership in retrieval, embeddings, and context engineering to power agentic AI Elastic (NYSE: ESTC), the Search AI Company, has completed the acquisition of Jina AI , a pioneer in open source multimodal and multilingual embeddings, reranker, and small language models. The acquisition deepens Elastic's capabilities in vector search, retrieval-augmented generation (RAG), and context engineering, further strengthening the company's position as the leading Search AI Platform for developers and enterprises. Elastic's addition of Jina AI demonstrates its continued commitment to delivering open, accessible, and production-ready Search AI at scale. "Search is the foundation of generative AI," said Ash Kulkarni, CEO, Elastic . "Jina AI's team and technology bring cutting-edge models into the Elastic ecosystem, making our platform even more powerful for context engineering. Together, we are expanding what developers and enterprises can achieve with
10.  [2] Date: Oct 9, 2025

13.  ### Elastic Completes Acquisition of Jina AI, a Leader in Frontier Models for Multimodal and Multilingual Search

16.  _Acquisition advances Elastic's leadership in retrieval, embeddings, and context engineering to power agentic AI_

`AI写代码![](https://csdnimg.cn/release/blogv2/dist/pc/img/runCode/icon-arrowwhite.png)

你可以仅执行搜索 ,而不尝试获取底层页面,只需添加请求头 X-Respond-With: no-content。例如:

arduino 复制代码
`1.  curl "https://s.jina.ai/Elastic+Jina" \
2.    -H "Authorization: Bearer <YOUR_API_KEY>" \
3.    -H "X-Respond-With: no-content"` AI写代码

这会返回以 Markdown 格式表示的文本,开头如下:

less 复制代码
`

1.  [1] Title: Elastic and Jina AI join forces to advance open source retrieval for AI ...
2.  [1] URL Source: https://www.elastic.co/blog/elastic-jina-ai
3.  [1] Description: We are thrilled to announce that Elastic has joined forces with Jina AI, a pioneer in open source multimodal and multilingual embeddings, ...
4.  [1] Date: Oct 9, 2025

7.  [2] Title: Elastic Completes Acquisition of Jina AI, a Leader in Frontier Models ...
8.  [2] URL Source: https://ir.elastic.co/news/news-details/2025/Elastic-Completes-Acquisition-of-Jina-AI-a-Leader-in-Frontier-Models-for-Multimodal-and-Multilingual-Search/default.aspx
9.  [2] Description: The acquisition of Jina AI broadens Elastic's leadership in relevance for unstructured data by adding dense vector, multilingual and multimodal ...
10.  [2] Date: Oct 9, 2025

13.  [3] Title: Jina AI - Elasticsearch Labs
14.  [3] URL Source: https://www.elastic.co/search-labs/integrations/jina
15.  [3] Description: Jina AI is now part of Elastic, bringing its high-performance multilingual and multimodal search AI to Elasticsearch's powerful data storage, retrieval, and ...

18.  [4] Title: Elastic Completes Acquisition of Jina AI, a Leader in Frontier Models ...
19.  [4] URL Source: https://finance.yahoo.com/news/elastic-completes-acquisition-jina-ai-130200685.html
20.  [4] Description: Elastic's addition of Jina AI demonstrates its continued commitment to delivering open, accessible, and production-ready Search AI at scale.
21.  [4] Date: Oct 9, 2025

`AI写代码![](https://csdnimg.cn/release/blogv2/dist/pc/img/runCode/icon-arrowwhite.png)

Reader 还提供结构化提取模式,如果你添加请求头 Accept: application/json,它会返回 JSON 结构化数据。例如,要执行与上面相同的搜索:

arduino 复制代码
 `1.   curl "https://s.jina.ai/Elastic+Jina" \
2.    -H "Authorization: Bearer <YOUR_API_KEY>" \
3.    -H "Accept: application/json"`AI写代码

这会以 JSON 格式返回相同的信息,方便其他应用程序访问,同时还包括一些页面 metadata 和 token 使用摘要。下面的示例输出为了可读性和节省空间,很多内容已被省略(用 <...> 代替):

bash 复制代码
`

1.  "data": [
2.   {
3.     "title": "Elastic Completes Acquisition of Jina AI, a Leader in Frontier Models for Multimodal and Multilingual Search",
4.     "url": "https://ir.elastic.co/news/news-details/2025/Elastic-Completes-Acquisition-of-Jina-AI-a-Leader-in-Frontier-Models-for-Multimodal-and-Multilingual-Search/default.aspx",
5.     "description": "Acquisition advances Elastic's leadership <...>",
6.     "date": "Oct 9, 2025",
7.     "content": "### Elastic Completes Acquisition of Jina AI<...>",
8.     "metadata": {
9.       "lang": "en-US",
10.       <...>
11.     },
12.     "usage": {
13.       "tokens": 1447
14.     }
15.   },
16.   {
17.     "title": "Elastic Completes Acquisition of Jina AI, a Leader in Frontier Models for Multimodal and Multilingual Search",
18.     "url": "https://finance.yahoo.com/news/elastic-completes-acquisition-jina-ai-130200685.html",
19.   <...>

`AI写代码![](https://csdnimg.cn/release/blogv2/dist/pc/img/runCode/icon-arrowwhite.png)

这个 API 还有更多选项。欲了解完整信息,包括可选参数及其对应的 headers,请访问 Reader API 页面。

Reader 与 Elasticsearch

Reader API 是一个方便的工具,用于执行表面看似简单但实际上并不简单的任务。网络环境足够复杂,你确实需要 AI 才能充分利用它。从网页和 PDF 中提取数据对程序员来说是一项杂乱的工作,但非常适合 AI 语言模型。

Reader 选择以 JSON 和 Markdown 作为标准格式,这反映了支持最有用、广泛支持、同时又简单且人类可访问的数据格式的策略。

你可以将 Markdown 直接放入 Elasticsearch 文档存储,并使用 Elastic Document API 提供的任意方法进行索引。最佳策略通常是先使用 Reader 获取文档,然后批量处理,或者在资源受限时使用尽可能大的批次。你可以将 Reader 输出与任何文本存储或索引策略结合使用。

Elasticsearch 在存储、索引和检索中对 JSON 提供直接支持。JSON 格式可供人工检查,可作为纯文本传输,并在所有主流编程语言和框架中有可靠支持,同时在浏览器中也内置支持。

Reader 通过将 AI 引入现实世界生成的杂乱数据,使你的 Elastic 安装更有用。

原文:www.elastic.co/search-labs...

相关推荐
ofoxcoding15 小时前
借助 CLAUDE.md 约束 Sonnet 5.5 多文件重构行为的提示词实践
大数据·elasticsearch·ai·重构
Elasticsearch15 小时前
隆重推出 AlertZero:让你的告警队列实现 “收件箱清零” 式管理
elasticsearch
ly768916 小时前
从 TF-IDF 到 BM25:Elasticsearch 相关性评分的字段长度归一化与 boost 调参边界
java·elasticsearch·query dsl·bm25·相关性评分
SL-staff16 小时前
技术实践:将Excel自动升级为可搜索的知识节点(JVS平台实现)
mongodb·elasticsearch·知识图谱·jvs平台·语义解析·企业文档管理·excel结构化
Elasticsearch16 小时前
2026 年唯一获得端点预防与响应(EPR)满分的厂商是 Elastic
elasticsearch
vx_Biye_Design16 小时前
springboot旅游管理系统18006-计算机课程设计、毕业设计
java·spring boot·后端·python·elasticsearch·django·课程设计
ly76891 天前
倒排索引与 FST 在 Lucene 中的内存布局:segment、docValues 与词典压缩的工程取舍
elasticsearch·lucene·倒排索引·doc values·fst
Elasticsearch1 天前
利用预计算上下文,更快速、更低成本地开展支持问题调查
elasticsearch
小小小米粒1 天前
重置本地git
大数据·git·elasticsearch
ly76891 天前
Spring Boot 集成 Elasticsearch 的生产实践:客户端选型、索引生命周期与批量写入容错
spring boot·elasticsearch·索引生命周期·java api client·批量写入