Skip to content

Commit 540ae89

Browse files
author
zhaoxuebin
committed
fix bug of alias
1 parent 130765c commit 540ae89

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elasticsearch-orm",
3-
"version": "1.0.16",
3+
"version": "1.0.17",
44
"description": "This is a orm for elasticSearch",
55
"main": "es.js",
66
"scripts": {

src/entity.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,18 @@ module.exports = function(name, opts, mappings = {}, settings) {
3838
'url': url,
3939
'method': 'GET'
4040
});
41-
let mappings = result[INDEX].mappings;
41+
let mappings = {};
42+
if (result[INDEX]) {
43+
mappings = result[INDEX].mappings;
44+
} else {
45+
Object.keys(result).some((key) => {
46+
let item = result[key];
47+
if (!!item.aliases) {
48+
mappings = item.mappings;
49+
}
50+
return false;
51+
});
52+
}
4253
flag = mappings.hasOwnProperty(TYPE);
4354
if (flag) {
4455
dbMappings = mappings[TYPE].properties;

0 commit comments

Comments
 (0)