Tag: elasticsearch

Elasticsearch映射

如何改变弹性search现有索引中的映射? 我需要设置geo_pointtypes的位置types。 { "stations": { "mappings": { "station": { "properties": { "address": { "type": "string" }, "district": { "type": "string" }, "location": { "properties": { "lat": { "type": "double" }, "lon": { "type": "double" } } }, "name": { "type": "string" } } } } } }

弹性search索引模板的创build

我对弹性search很新,在我使用弹性search的节点程序中。 在这个我试图创build一个"Index Template"但我收到错误: 查询: client.indices.putTemplate({ "name":"mfi1", "template" : "te*" }).then(function(res){ console.log(res); }, function(error){ console.log(error); }); 但是我收到错误: { "error": "ElasticsearchParseException[Failed to derive xcontent from org.elasticsearch.common.bytes.BytesArray@1]", "status": 400 } 帮我解决这个问题。

在nodejs中使用elasticsearch获取基于属性值的文档

我正在使用Elasticsearch,我是这个技术的新手。我不知道如何使用nodej来search弹性search中的索引types的属性值。我的数据是 { "line_num": 1, "action1": "ORIGINAL", "process_code1": "PENDING", "isPR": "Y", "req_header_reference_num": "PC5298", "req_line_reference_num": "PC5298", "pr_line_no": "1", "pr_id": "ffd3f7cc6", "pr_po_flag": "N", "pr_item_id": "720541" } 从这个数据我想基于属性值进行search。 示例如果我给“ORIGINAL” ,在此基础上从elasticsearch中获取特定文件那么如何解决这个问题呢先谢谢

Elasticsearch NodeJSsearch:如何从响应中检索结果

我正在尝试使用节点js在Elasticsearch中进行search。 这是我的脚本 var elasticsearch = require('elasticsearch'); var client = elasticsearch.Client({ host: 'localhost:9200', log: 'trace' }); client.ping({ // ping usually has a 3000ms timeout requestTimeout: Infinity, // undocumented params are appended to the query string hello: "elasticsearch!" }, function (error) { if (error) { console.trace('elasticsearch cluster is down!'); } else { console.log('All is well'); getmeres(client); } […]

nodejs SyntaxError:意外的标记

我正在使用elasticsearch-exporter从Elasticsearch导出数据。 该工具最初是一个nodejs应用程序。 当我尝试使用下面的命令node exporter.js使工具列出所有可用的选项时,它会崩溃,出现以下exception /home/me/storage/Elasticsearch-Exporter/log.js:54 exports.error = (…args) => !capture("ERROR", args) && console.log(timestamp() + util.format(…args).red); ^^^ SyntaxError: Unexpected token … at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:374:25) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at Object.<anonymous> (/home/anas/storage/Elasticsearch-Exporter/exporter.js:9:11) at Module._compile (module.js:410:26) at Object.Module._extensions..js (module.js:417:10) 这里是抛出exception的行 exports.error = (…args) => […]

如何在elastic.js(elasticsearch)中计算具有相同值的字段?

我有一个社区的名单。 我需要创build聚合查询,它将统计所有具有相同标题的数据。 [ { "_id": "56161cb3cbdad2e3b437fdc3", "_type": "Comunity", "name": "public", "data": [ { "title": "sonder", "creationDate": "2015-08-22T03:43:28 -03:00", "quantity": 0 }, { "title": "vule", "creationDate": "2014-05-17T12:35:01 -03:00", "quantity": 0 }, { "title": "omer", "creationDate": "2015-01-31T04:54:19 -02:00", "quantity": 3 }, { "title": "sonder", "creationDate": "2014-05-22T05:09:36 -03:00", "quantity": 3 } ] }, { "_id": "56161cb3dae30517fc133cd9", "_type": "Comunity", […]

在Node.js中构build“filter代理”

我有一个elasticsearch服务器,我想查询,但在向用户显示结果之前,我想过滤结果(在数据库中查找用户权限等) 所以我想我写了一个代理服务器接收JSON POSTsearch请求,并将其redirect到Elasticsearch服务器。 现在将结果的响应发送到“filter服务器”。 这个服务器在数据库中查找收到的json数据,并删除用户不被允许查看的结果。 这个过滤的内容应该呈现给用户。 好的 – 这就是我所做的: var proxy = http.createServer(function (req, res){ if(req.method == 'OPTIONS'){ res.writeHead(200, {'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json; charset=UTF-8'}); res.end(); } if(req.method == 'POST'){ var searchOptions = { host: '10.0.10.1', port: 9200, method: 'POST', path: '/ltg_5096/_search' } var searchRequest = http.request(searchOptions, function(searchResponse){ // this is the Request to the Elasticsearch […]

如何在使用elasticjs v5.0的文档中没有id的情况下自动生成id

我试图添加文件,根据弹性search文件,我们可以添加文件,即使我们不提供身份证… 看到这里 我试图添加一个文件,即使它没有任何ID。 在弹性search中,我该怎么做? 我目前的代码是这样的 var params = _.defaults({}, { index: index, type: type, //'customer' id: data.id || null, body: data }) debug(params) return this.client.create(params); 上面的代码给出了这个错误 {“error”:“无法用这些参数build立path,至less提供索引,types,id”} 任何提示将有所帮助,谢谢

node.js:通过使用用户定义的id在elasticsearch中进行数据索引

我需要在elasticsearch中索引多个jsons,索引id应该由用户自己创build而不是由elasticserach自动创build。 可以任何请告诉我如何停止elasticsearch创build自动索引id,我怎样才能使用我想要的数据索引编号。 以下是用于索引数据的node.js代码的一部分: elasticSearchClient.index('index_name', 'type', json) .on('data', function(data) { console.log("************ "+data+" ****************") }) .exec() 任何帮助将不胜感激! 问候

如何为elasticsearch做create_or_update?

我有一个简单的例子: var client = new elasticsearch.Client({ host: 'localhost:9200' }); client.create({ index: 't1', type: 't2', id : id, body: row},function(err,results) { callback(err, results ) }) 如果logging存在,则结果错误:DocumentAlreadyExistsException。 如果logging存在,如何更新logging?