【问题标题】:Elasticsearch ERROR, The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefinedElasticsearch 错误,“数据”参数必须是字符串类型或 Buffer、TypedArray 或 DataView 的实例。收到未定义
【发布时间】:2021-10-27 22:05:37
【问题描述】:

AWS Elasticsearch 集群通过 nodejs 连接。

const AWS = require('aws-sdk')
const elasticsearch = require('elasticsearch')
const awsHttpClient = require('http-aws-es')

let client = elasticsearch.Client({
    host: 'http://---.us-east-1.es.amazonaws.com/',
    connectionClass: awsHttpClient,
    amazonES: {
        region: 'us-east-1',
        credentials: new AWS.Credentials('----', '-----')
    }
});

client.search({
    index: 'orders',
    type: 'text',
    body: {
        query: {
            match: {
                source: 'ETH'
            }
        }
    }
})
.then(res => console.log("Error : ",res));

Elasticsearch 错误:2021-08-28T07:40:03Z 错误:请求错误, 重试 POST http://-------.us-east-1.es.amazonaws.com/eth_orders/_search?type=text => "data" 参数必须是字符串类型或 Buffer、TypedArray 或 DataView 的实例。收到未定义 在 Log.error (C:\Users\genie\node_modules\elasticsearch\src\lib\log.js:239:56) 在 checkRespForFailure (C:\Users\genie\node_modules\elasticsearch\src\lib\transport.js:298:18) 完成后(C:\Users\genie\node_modules\http-aws-es\connector.js:48:7) 在 processTicksAndRejections (internal/process/task_queues.js:95:5)

Elasticsearch 警告:2021-08-28T07:40:03Z 无法恢复 联系: http://-----.us-east-1.es.amazonaws.com/

Elasticsearch 警告:2021-08-28T07:40:03Z 没有实时连接

(node:18256) UnhandledPromiseRejectionWarning: 错误: 没有生命 连接 在 sendReqWithConnection (C:\Users\genie\node_modules\elasticsearch\src\lib\transport.js:266:15) 在下一个(C:\Users\genie\node_modules\elasticsearch\src\lib\connection_pool.js:243:7) 在 processTicksAndRejections (internal/process/task_queues.js:77:11) (使用node --trace-warnings ... 显示警告的创建位置)(节点:18256) UnhandledPromiseRejectionWarning:未处理的承诺拒绝。这 错误源于在异步函数内部抛出 没有 catch 块,或拒绝未处理的承诺 使用 .catch()。在未处理的承诺上终止节点进程 拒绝,请使用 CLI 标志 --unhandled-rejections=strict(请参阅 https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)。 (拒绝 id:1)(节点:18256)[DEP0018] DeprecationWarning:未处理 不推荐使用承诺拒绝。在未来,承诺拒绝 未处理的将终止 Node.js 进程 非零退出代码。

我遇到了这些错误,谁能帮忙。

【问题讨论】:

    标签: node.js elasticsearch aws-elasticsearch


    【解决方案1】:

    Doctypes 在最新的 Elasticsearch 版本中不可用,因此可能只需删除 type: 'text',

    client.search({
        index: 'orders',
        body: {
            query: {
                match: {
                    source: 'ETH'
                }
            }
        }
    })
    

    【讨论】:

    • 它的连接错误,我必须为此做些什么。
    猜你喜欢
    • 2021-08-07
    • 2021-03-16
    • 2022-01-21
    • 2021-06-10
    • 2022-11-11
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 2021-08-18
    相关资源
    最近更新 更多