typescript - 如何使用新的 elasticsearch typescript 类型
问题描述
我想根据这个 TypeScript 支持使用新的弹性搜索类型 | Elasticsearch Node.js 客户端 [7.x] | 弹性 1 文件,但如果我这样做
// try the new code completion when building a query!
const response = await client.search<Source>({
index: 'test',
body: {
query: {
match_all: {}
}
}
})
// try the new code completion when traversing a response!
const results = response.body.hits.hits.map(hit => hit._source)
// results type will be `Source[]`
console.log(results)
我的结果对象本身是我提供的类型而不是 SearchResponse
解决方案
需要使用elasticsearch节点模块版本>=7.13才能使用新类型支持
推荐阅读
- angular - 您好,我在发出 http 删除请求时收到以下错误
- scala - Scala“无法在对象 CassandraConnector 中访问 DCAwareRoundRobinPolicy 类中的构造函数 DCAwareRoundRobinPolicy”
- html - 有条件地禁用Angular中的标签
- php - Laravel:如何在用户注册表单中添加下拉列表
- postgresql - 在 adminer 中查看 postgresql json 表作为(可排序的)表
- r - 整齐地附加许多列的最佳方法是什么?
- r - 是否有一个 R 函数可以仅根据条件部分更改多个变量名称?
- django - 无法序列化 django 信号中的模型对象
- google-bigquery - BigQuery 中的映射(动态键)
- java - Spring忽略类加载器