think_elasticsearch
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -266,2 +266,27 @@ 'use strict'; | ||
/** | ||
* 直接根据id查询 | ||
* @param _id | ||
*/ | ||
_class.prototype.get = function get(_id) { | ||
var _this4 = this; | ||
return this.socket().connect().then(function (conn) { | ||
return _this4.socket().connect().then(function (conn) { | ||
var condition = { | ||
index: _this4.queryObj.index, | ||
type: _this4.queryObj.type, | ||
id: _this4.queryObj.body.query.id | ||
}; | ||
_this4.logSql && _lib2.default.log((0, _stringify2.default)(condition), 'ES', Date.now()); | ||
return conn.get(condition); | ||
}).then(function (data) { | ||
//this.close(); | ||
return data; | ||
}); | ||
}); | ||
}; | ||
/** | ||
* 创建索引 | ||
@@ -545,3 +570,8 @@ * @param index | ||
this.queryBuilder(opitons, 'select'); | ||
return this.query(); | ||
//如果存在_id项,则直接查询 | ||
if (opitons.hasOwnProperty('where') && (opitons.where.hasOwnProperty('_id') || opitons.where.hasOwnProperty('id'))) { | ||
return this.get(opitons.where.hasOwnProperty('_id') || opitons.where.hasOwnProperty('id')); | ||
} else { | ||
return this.query(); | ||
} | ||
}; | ||
@@ -548,0 +578,0 @@ |
{ | ||
"name": "think_elasticsearch", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"description": "基于elasticsearch.js的elasticsearch工具", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -174,2 +174,23 @@ /** | ||
/** | ||
* 直接根据id查询 | ||
* @param _id | ||
*/ | ||
get(_id) { | ||
return this.socket().connect().then(conn=> { | ||
return this.socket().connect().then(conn=> { | ||
let condition = { | ||
index: this.queryObj.index, | ||
type: this.queryObj.type, | ||
id: this.queryObj.body.query.id | ||
} | ||
this.logSql && lib.log(JSON.stringify(condition), 'ES', Date.now()); | ||
return conn.get(condition); | ||
}).then(data=> { | ||
//this.close(); | ||
return data; | ||
}) | ||
}) | ||
} | ||
/** | ||
* 创建索引 | ||
@@ -420,3 +441,8 @@ * @param index | ||
this.queryBuilder(opitons, 'select'); | ||
return this.query(); | ||
//如果存在_id项,则直接查询 | ||
if (opitons.hasOwnProperty('where') && (opitons.where.hasOwnProperty('_id') || opitons.where.hasOwnProperty('id'))) { | ||
return this.get(opitons.where.hasOwnProperty('_id') || opitons.where.hasOwnProperty('id')); | ||
} else { | ||
return this.query(); | ||
} | ||
} | ||
@@ -423,0 +449,0 @@ |
@@ -12,3 +12,3 @@ /** | ||
db_type: 'es', // 数据库类型 | ||
db_host: '192.168.1.1', // 服务器地址 | ||
db_host: '', // 服务器地址 | ||
db_port: '9200', // 端口 | ||
@@ -29,12 +29,12 @@ db_log: 'info' | ||
//}) | ||
.setIndex('am') | ||
.setType() | ||
.limit(1, 1000) | ||
.setIndex('am_test') | ||
.setType('list') | ||
.where({id: '5e97ab25b4620e6a7f027647e6dc3615'}) | ||
//.field('goods,price') | ||
.selectAll().then(res => { | ||
//console.log(res.hits.hits.length) | ||
res.hits.hits.map(item=> { | ||
"use strict"; | ||
console.log(item) | ||
}) | ||
.find().then(res => { | ||
console.log(res) | ||
//res.hits.hits.map(item=> { | ||
// "use strict"; | ||
// console.log(item) | ||
//}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
740106
5564