在Elasticsearch中使用nodejs创build索引时出错
我正在使用npm elasticsearch,因为得到这样的错误
client.index不是一个函数
这是我的代码
encryptObj = enpyt.encrypt(function(encrypted){ client.index({ index: 'collectionnew3 id: '101', type: 'collectiontype3', body: { "username": "postgres", "pswrd": encrypted, } },function(err,resp,status) { console.log(resp); }) })
任何想法,为什么我得到这个?
正如评论所说,似乎client
没有正确实例化。
在node.js中实例化Elasticsearch客户端的示例:
var elasticsearch = require('elasticsearch'); var client = new elasticsearch.Client({ host: "http://localhost:9200", apiVersion: "2.3" });
- node.js lambda函数将logging从sql迁移到elasticsearch,使用队列限制asynchronous调用
- 如何在不使用Base64的情况下在ElasticSearch中索引二进制文件
- 弹性search创build基于时间的索引
- 如何在Elasticsearch中创build或replace文档?
- 如何在使用摩卡进行集成testing时处理elasticsearch的索引时间
- 将elasticsearch js和bluebird结合起来
- 使用cassandra和elasticsearch后端制作我的titan db图
- 将mongodb与云托pipe的elasticsearch整合在一起
- NodeJs-ElasticSearch批量APIerror handling