node.js-索引elasticsearch文档-直到infity
我是Node.js的新手-希望不要问愚蠢的问题 我正在尝试将一个文档索引到elasticsearch中,这是可行的node.js-索引elasticsearch文档-直到infity,node.js,
elasticsearch,Node.js,
elasticsearch,我是Node.js的新手-希望不要问愚蠢的问题 我正在尝试将一个文档索引到elasticsearch中,这是可行的 var elasticsearch = require('elasticsearch'); function writetoela(information){ var client = elasticsearch.Client({ host: 'server03:9200' }); client.index({ index: 'f
var elasticsearch = require('elasticsearch');
function writetoela(information){
var client = elasticsearch.Client({
host: 'server03:9200'
});
client.index({
index: 'fhem',
type: 'state',
body: {
time: information.time,
alias: information.alias,
state: information.state,
room: information.room
}
})}
我的问题是从索引文档之后开始的。该函数不会退出,因此我可以执行其他操作
通过以下行调用上述函数:
index_data.writetoela(data);
“数据”是一个值数组,应该索引到elasticsearch
有人能告诉我,为什么会这样
谢谢
Bjoern对我来说应该是这样的:
var elasticsearch = require('elasticsearch');
function writetoela(information){
var client = elasticsearch.Client({
host: 'server03:9200'
});
client.index({
index: 'fhem',
type: 'state',
body: {
time: information.time,
alias: information.alias,
state: information.state,
room: information.room
}
}, function (err, resp) {
// handle the error response here
console.info(err);
console.info(resp);
});
要调试应用程序,请使用nodeinspector:
Hi-只是想知道你是否设法弄明白为什么函数永远不会返回?我也遇到同样的问题,我不知道为什么。我已经在Windows和Ubuntu上进行了测试,同样的问题也出现了。亲爱的@M.Y.,我最终使用了elasticsearch的RESTAPI和。。。工作非常简单,你只需要通读elasticsearch的RESTAPI的文档。。。(他们提供了一些例子…)很酷。谢谢你的回复!