Tag: elasticsearch

将数据从Node.jsstream上传到ElasticSearch数据库

我目前的Node.js代码从一个非常大的USPTO专利XML文件(大约100mb)创build一个stream,并在parsingXMLstream时创build一个patentGrant对象。 专利授权对象包括出版号,出版国,出版date和专利种类。 我正在尝试使用ElasticSearch创build一个包含所有patentGrant对象的数据库。 我已成功添加代码以连接到本地ElasticSearch数据库,但是我无法理解ElasticSearch-js API。 我不知道应该如何将专利授权对象上传到数据库。 从以下教程和之前的一个计算器问题,我在这里问。 好像我应该使用批量API 。 下面是我的ParseXml.js代码: var CreateParsableXml = require('./CreateParsableXml.js'); var XmlParserStream = require('xml-stream'); // var Upload2ES = require('./Upload2ES.js'); var parseXml; var es = require('elasticsearch'); var client = new es.Client({ host: 'localhost:9200' }); // create xml parser using xml-stream node.js module parseXml = new XmlParserStream(CreateParsableXml.concatXmlStream('ipg140107.xml')); parseXml.on('endElement: us-patent-grant', function(patentGrantElement) { var patentGrant; […]

将elasticsearch js和bluebird结合起来

我开始使用蓝鸟承诺框架node.js。 我正在尝试将其与elasticsearch javascript驱动程序集成。 我设法使用下面的代码工作。 我想知道这是否是启动承诺的最佳方式。 我省略了在后续步骤中调用的函数。 var esPromise = client.search({ index: "myindex", searchType: "count", body: { aggs: { allIp: { terms: { field: "ip", size: 1000, order: { _term: "asc" } } } } } }); new Promise(function (resolve, reject) { esPromise.then(resolve, reject); }) .then(extract_ips_from_aggs) .then(sort_ips) .then(log_ips) .catch(function (error) { console.log(error); });

如何在节点js中的ElasticSearch快照?

环境描述: ElasticSearch:v1.4.3 NodeJS:v0.12.7 我想用nodeJs API做一个ElasticSearch集群的快照。 我看API文档,但没有一个例子,所以我甚至不知道如何写它。 我唯一拥有的是语法: client.snapshot.create([params, [callback]]) 你可以看到这里的文档: 这里 我试着去做: client.snapshot.create({"waitForCompletion":true, "snapshot":"snapshot_4", "repository":"my_backup"}); 但它给了我这个错误: Unhandled rejection Error: InvalidIndexNameException[[_snapshot] Invalid index name [_snapshot], must not start with '_'] at respond (D:\Users\ermaro\Documents\SG\kyc\trunk\kyc\node_modules\elasticsearch\src\lib\transport.js:256:15) at checkRespForFailure (D:\Users\ermaro\Documents\SG\kyc\trunk\kyc\node_modules\elasticsearch\src\lib\transport.js:219:7) at HttpConnector.<anonymous> (D:\Users\ermaro\Documents\SG\kyc\trunk\kyc\node_modules\elasticsearch\src\lib\connectors\http.js:155:7) at IncomingMessage.wrapper (D:\Users\ermaro\Documents\SG\kyc\trunk\kyc\node_modules\lodash\index.js:3095:19) at IncomingMessage.emit (events.js:129:20) at _stream_readable.js:908:16 at process._tickCallback (node.js:355:11) 有没有人试过这个提示? 谢谢

Mac OS X上的ElasticSearch + Node Yosemite:JRE崩溃?

这一点有些莫名其妙,可能是因为我没有经常遇到JRE核心转储。 我正在为Node.js使用官方的ElasticSearch模块,并试图在我的一个索引中创build一个新的文档。 我的节点应用程序似乎连接到ES实例就好了,但是当我执行create请求时,我的JRE咬了灰尘! 这里是节点吐出的错误: Elasticsearch INFO: 2015-12-16T21:40:47Z Adding connection to http://my.server.address/:9200 Elasticsearch DEBUG: 2015-12-16T21:40:53Z starting request { method: 'POST', path: '/test/document', body: { foo: 'bar' }, query: { op_type: 'create' } } # # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00000001004f3616, pid=40975, tid=1299 # # […]

client.indices.putTemplate和client.putTemplate之间的区别

使用Javascript ElasticSearch客户端Elasticsearch.js , client.indices.putTemplate和client.putTemplate之间有什么区别

如何在使用摩卡进行集成testing时处理elasticsearch的索引时间

我正在研究一个使用elasticsearch的节点项目。 我的testing链是吞咽,摩卡,柴,sin。 我很难让我的集成testing始终如一地工作。 我想加载数据库中的示例数据,然后运行一些testing。 我相信我有问题,因为我正在加载的文件没有索引我的testing使用它们运行的​​时间。 我已经通过执行以下操作来解决此问题: before(function (done) { testData.simpleLoadData(100, 2000); setTimeout(function () { done(); }, 5000); }); 这在当地正常工作,偶尔对travis有效。 当我把计时器升到10000时,一般都在两个地方工作。 有没有办法在这个testing代码诉诸setTimeouts? 手动处理时间使我有点娇气。 手动处理超时我有最好的select还是有更好的方法? 注意:这些是集成testing,我明确地想要使用外部依赖关系。 我有单位testing,不依赖于数据库已经。

在node.js中获取json输出(使用elasticsearch和express作为web框架)

我正在使用node.js在elasticsearch之上构buildsearch引擎Web应用程序。 我已经用elasticsearch索引了一个网站,现在使用我的索引来构build一个网页。 这是我的javascript: var elasticsearch = require('elasticsearch'); var client = elasticsearch.Client({ hosts: [ 'localhost:9200' ] }); module.exports.search = function(searchData, callback) { client.search({ index: 'demoindex1', type: 'SearchTech', body: { query: { bool: { must: { match: { "newContent": searchData.searchTerm } } } } } }).then(function (resp) { callback(resp.hits.hits); }, function (err) { callback(err.message) console.log(err.message); }); } […]

Elasticsearch匹配给定数组中的所有标签

目前正在使用elasticsearch开发一个标签search应用程序,我已经给索引中的每个文档提供了一个标签数组,下面是一个文档外观的例子: _source: { title: "Keep in touch scheme", intro: "<p>hello this is a test</p> ", full: " <p>again this is a test mate</p>", media: "", link: "/training/keep-in-touch", tags: [ "employee", "training" ] } 我希望能够进行search,并只返回所有指定标签的文档。 使用上面的例子,如果我search了一个标签["employee", "training"]的文档,那么上面的结果将被返回。 相反,如果我用标签["employee", "other"] ,则不会返回任何内容。 search查询中的所有标签都必须匹配。 目前我在做: query: { bool: { must: [ { match: { tags: ["employee","training"] }} ] } […]

在node.js环境中将mongodb与elasticsearch集成在一起

我正在做一个有如下设置的项目: 我有一个Amazon EC2集群,有一个主服务器,3个configuration服务器和3个分片服务器。 Master有一个node.js应用程序,它基本上是一个使用Express.js模块编写的REST API。 我正在使用MongoDB作为数据库。 Master有“mongos”服务运行,将数据分割成3个分片服务器。 这些服务器上运行着“mongod”服务。 有了这个设置,我想整合elasticsearch来执行search查询。 为了做到这一点,我想在我的node.js REST API应用程序中添加一个path,以对存储在分片中的数据执行search查询。 考虑到我在独立机器上运行三个碎片,是否还有其他步骤? 如何configurationelasticsearch访问分片中的数据来构build索引? 它会自动检测这个configuration并build立索引吗? 有人可以给我提供我应该遵循的步骤来完成这个步骤吗?

ElasticSearch client.indices.putMapping总是失败

我真的不明白这个文件。 即使读了几个SO问题和答案(例如: 这一个 )。 我有这个代码 let indexMapping = { 'foo': { name: { type: 'string', index: 'analyzed' }, value: { index: 'no' }, dynamic_templates: [ { customRule: { path_match: 'bar.*', mapping: { type: '{dynamic_type}', index: 'no' } } } ] } }; let indexName = 'foos'; let typeName = 'foo'; client.indices.putMapping({ index: indexName, type: typeName, […]