@elastic/enterprise-search

中文文档
8.18.0发布于 2025/04/22Apache-2.0TypeScriptCommonJS近 30 天下载 3.3万

Official Node.js client for Elastic Enterprise Search, App Search, and Workplace Search.

原始使用文档
文档目录3 节
  1. Install
  2. Quick start
  3. License

:warning: App Search and Workplace Search will be discontinued in 9.0

Starting with Elastic version 9.0, the standalone Enterprise Search products, will no longer be included in our offering. They remain supported in their current form in version 8.x and will only receive security upgrades and fixes. Enterprise Search clients will continue to be supported in their current form throughout 8.x versions, according to our EOL policy. We recommend transitioning to our actively developed Elastic Stack tools for your search use cases. However, if you're still using any Enterprise Search products, we recommend using the latest stable release of the clients.

Here are some useful links with more information:

Elastic Enterprise Search

js-standard-style Build Status. Node CI

Official Node.js client for Elastic Enterprise Search, App Search, and Workplace Search.

:information_source: Read the full documentation for this client at elastic.co.

Install

npm install @elastic/enterprise-search

Quick start

const { Client } = require('@elastic/enterprise-search')
const client = new Client({
  url: 'http://localhost:3002',
  // basic auth
  auth: {
    username: 'elastic',
    password: 'changeme'
  }
  // bearer auth
  auth: {
    token: 'my-token'
  }
})

// Enterprise Search API
const response = await client.enterprise.getHealth()
console.log(response)

// App Search API
const response = await client.app.search({
  engine_name: 'games',
  body: {
    query: 'Pack-Man'
  }
})
console.log(response)

// Workplace Search API
const response = await client.workplace.getDocument({
  content_source_id: 'test',
  document_id: 'id'
})
console.log(response)

License

This software is licensed under the Apache 2 license.

版本与发布记录

@elastic/enterprise-search 共发布 5 个版本,首次发布于 2022/03/22;过去 12 个月发布了 0 个版本。

版本发布日期距今
8.18.0latest2025/04/221.6 年前
8.6.12023/11/152 年前
8.6.02023/01/283 年前
8.1.1-beta.12022/11/044 年前
8.1.0-beta.12022/03/224 年前

关于 @elastic/enterprise-search 的常见问题

@elastic/enterprise-search 是什么?

Official Node.js client for Elastic Enterprise Search, App Search, and Workplace Search.

如何安装 @elastic/enterprise-search?

在项目目录运行 npm install @elastic/enterprise-search,或使用 pnpm add / yarn add / bun add。

@elastic/enterprise-search 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@elastic/enterprise-search 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@elastic/enterprise-search 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@elastic/enterprise-search 可以商用吗?

@elastic/enterprise-search 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@elastic/enterprise-search 的下载量有多少?

根据 npm 官方下载统计,@elastic/enterprise-search 在 2026/10/14 – 2026/11/12 这 30 天内被下载 33,347 次,日均约 1,112 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@elastic/enterprise-search 还在维护吗?

最新版本 8.18.0 发布于 2025/04/22(1.6 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/03/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。