Tag: elasticsearch

ElasticSearch创build索引types错误

我正在使用elasticsearch npm模块。 创build索引会导致TypeError的消息是: Unable to build a path with those params. Supply at least index 我正在使用的代码如下所示: var client = new elasticsearch.Client({ host: 'localhost:9200', log: 'trace' }); client.indices.create('myindex', function (err, resp) { if (err) console.log('failed to create ElasticSearch index, ' + err.message); else console.log('successfully created ElasticSearch index'); }); 根据索引创build文档 ,我应该能够传递一个string与索引的名称。 我很困惑,为什么它一般是失败的,为什么错误信息是指一条path。

Elasticsearch分页与MongoDB和ExpressJS

我试图在网上search解决scheme,但说实话,我仍然没有发现任何有助于我实现这一目标的东西。 这是我第一次使用ElasticSearch,对于Node和MongoDB我也很新。 所以,我遵循了一种教程,并从NPM中实现了Mongooastic,让ElasticSearch和Node一起工作。 它似乎工作正常,即使总共有12个用户索引,如果我在search列表视图中键入search“用户”,我可以find12条logging,它显示10在每个和第一个缺less值。 .. 但是对我来说,主要的问题是分页…或者某种…实现无限滚动也是很好的,但是我不知道如何处理它。 所以,目前处理它的控制器如下: exports.searchUsers = function(req, res) { User.search({ query_string: { query: req.query.q } }, { hydrate: true }, function(err, results) { if (err) res.send(err); res.render('search-results', { results: results, users: results.hits.hits }); }); }; 我真的不知道在哪里放大size , from这里…了解了这一点,我也想知道如何实现,如果可能的话,一种无限的滚动…以及如何处理链接分页…即: prev, 1, 2, 3, 4, …, next 该视图有一个简单的searchinput文本,按提交后打开一个新的页面与hits列表,所以它应该没有什么复杂的… … 我希望你能帮忙。 谢谢

Elasticsearch _bulk更新问题给出VersionConflictEngineException消息

我在我的一个项目中使用elasticsearch。 我在更新logging时遇到问题。 我得到的错误信息是: – { _index: 'makes', _type: 'make', _id: '55b8cdbae36236490d00002a', status: 409, error: 'VersionConflictEngineException[[makes][0] [make][55b8cdbae36236490d00002a]: version conflict, current [168], provided [167]]' } 使用ES散装API。 我的应用程序在node.js. 让我分享我的代码: var conditions = []; conditions.push({ update: { _index: config.elasticSearch.index, _type: config.elasticSearch.type, _id: id } }); conditions.push({ doc: { published: true } }); client.bulk({ body: conditions }, function(err, resp) { […]

卡夫卡到node.js的Elasticsearch消费

我知道有相当多的node.js模块实现了一个Kafka消费者,它获取消息并写入弹性。 但是我只需要每个msg的一些字段,而不是全部。 有没有我不知道的现有解决scheme?

通过http正确签署对aws资源的请求

我有一个lambda函数,正在写一些数据到我也通过AWS设置的Elasticsearch域。 目前我的域名上的访问策略只是允许我自己的IP地址与域名一起工作 {"Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": {"AWS": "*"}, "Action": "es:*", "Resource": "arn:aws:es:us-east-1:$ACCOUNT:domain/DOMAIN/*", "Condition": { "IpAddress": { "aws:SourceIp": $MYIP } } }]} 我find了用于签署http请求的aws4库 。 我正在使用它: axios(aws4.sign({ host: process.env.ES_ENDPOINT, method: "post", url: `https://${process.env.ES_ENDPOINT}/foobot/foobot`, data, })) 这实际上是没有aws4.sign作品,因为我有ES域完全打开,但现在我已经应用了上面的IP地址策略。 现在,我不断得到这样的错误,作为回应: 我们计算的请求签名与您提供的签名不符。 检查您的AWS秘密访问密钥和签名方法。 详细信息请参阅服务文档。 还有什么我需要做的,以妥善签署请求?

如何在Elasticsearch中创build或replace文档?

我只是想创build或replace文档,但API文档不清楚如何做到这一点。 upsert示例显示正在创build一个counter值为1的文档: client.update({ index: 'myindex', type: 'mytype', id: '777', body: { script: 'ctx._source.counter += 1', upsert: { counter: 1 } } }, function(error, response) { // … }) 我不需要增量脚本,所以我尝试自己发送一个upsert,但我得到一个400 Validation Failed: 1: script or doc is missing : client.update({ index: "testindex", type: "testType", id: 1234, body: { upsert: { itworks: true, ok: "oh yeah" } […]

为什么Elasticsearch批量API不能parsing我的JSON?

我将这个类似JSON的数据通过HTTP请求发送到Elasticsearch API / _bulk端点: {"update":{"_id":1,"_type":"myType","_index":"myIndex"}} {"doc":{"id":1,"name":"Foo"},"doc_as_upsert":true} {"update":{"_id":2,"_type":"myType","_index":"myIndex"}} {"doc":{"id":2,"name":"Bar"},"doc_as_upsert":true} 当我通过邮递员(一个谷歌浏览器应用程序)的数据,它成功的工作。 当我通过我的Node.js脚本( request()调用)的PUT数据,我得到这个错误: { "error" : { "root_cause" : [ { "type" : "parse_exception", "reason" : "Failed to derive xcontent" } ], "type" : "parse_exception", "reason" : "Failed to derive xcontent" }, "status" : 400 } 我发送(我认为是)两种方式完全相同的数据,但只有邮递员正在工作。 我用\ n字符(包括最后一个)结尾每一行,我相信我的格式是正确的。 有什么我做错了吗? 编辑:节点代码(简体): var sourceData = JSON.parse(fs.readFileSync('test-data.json', 'utf8')), sourceData.forEach(function(data) […]

如何在不使用Base64的情况下在ElasticSearch中索引二进制文件

我正在使用NodeJS elasticsearch包与ElasticSearch进行交互。 我有一个文件有一个file字段。 我想能够上传一个文件到索引,但唯一的办法,我发现是通过使用elasticsearch-mapper-attachment插件。 问题是,如果我使用它,我必须加载整个文件在内存中,编码到Base64,然后将string传递给ElasticSearch。 我希望能够传递stream到ElasticSearch(引用任何二进制文件:pdf,xls,doc,ppt)。

putMapping elasticsearch索引找不到exception

我只是试图使用putMapping创build一个索引,并相当肯定这是一个语法问题。 弹性客户端正在为.index和.search命令工作,所以我不相信它的设置是问题。 相反,它是我的putmapping代码的东西。 任何build议将不胜感激。 我想要做什么的一点描述。 我search了一个索引,发现它不存在。 我发现错误并testing它是否等于“index_not_found_exception”。 如果是这样,我需要创build索引。 “…”下面的所有内容都在.catch中。 "use strict"; let config = require("./config"), soap = require("soap"), elastic = require("elasticsearch").Client(config.routeHost); … if (error.body.error.type == "index_not_found_exception") { console.log("no index"); elastic.indices.putMapping({ index: "ppvevents", type: "ppvObject", body: { properties: { name: {type: "string", index: "not_analyzed"}, hdid: {type: "integer"}, sdid: {type: "integer"} } } }).then(function(response){ console.log("Response: ", response); […]

当字段未定义或从对象丢失时从elasticsearch获取数据

我试图从弹性search中获取数据,通过查询指示对象是否已被处理的字段。 让我们把它叫做'isHandled'。 有一些没有这个字段索引的对象。 有没有办法得到“isHandled”只是不是“真”(假或甚至失踪)的数据? 谢谢