【发布时间】:2020-07-21 15:12:24
【问题描述】:
我在我的节点项目中使用@elastic/elasticsearch 库,我正在尝试创建这样的索引
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
await client.index({
index: 'myIndex',
refresh: true,
body: {
category: '',
something_else: ''
}
})
当我试图获取记录时
const { body } = await client.search({
index: 'myIndex',
body: {
query: {
"match_all": {}
}
}
})
回复是
{
"_index": "myIndex",
"_type": "_doc",
"_id": "cjijWHEBHKa8WEr-JNYu",
"_score": 1,
"_source": {}
},
【问题讨论】:
-
已提供答案,请看一下,如果有其他问题,请告诉我
-
只是我写了一个空白文本的例子..我实际上是在那里传递数据。
-
你能分享一下你的ES映射吗?希望你没有在你的映射中禁用它 { "mappings": { "_source": { "enabled": false } } } 像这样?
-
{"myIndex":{"mappings":{}}}
-
我也试过了,请问你用的是什么版本?
标签: node.js elasticsearch koa