在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" });
- Elasticsearch – 按优先级例外进行过滤和按名称sorting
- 卡夫卡到node.js的Elasticsearch消费
- 没有活连接在nodejs中的Elasticsearch连接时出错
- 如何为elasticsearch做create_or_update?
- 对elasticsearch的GET请求中的'request_cache = true'不会创buildcaching
- 弹性search:了解如何优化写入操作,使读取不受影响
- ElasticSearch重新启动花费很长时间
- putMapping elasticsearch索引找不到exception
- Elasticdump中的'现在不能切换到旧模式'错误