Skip to content

Commit

Permalink
通过索引别名获取mapping,返回数据为真实索引,而不是别名,导致mappings.get(index).get(type)报空指针异常 (
Browse files Browse the repository at this point in the history
  • Loading branch information
xyz487 authored May 13, 2022
1 parent 11a5f2a commit e48bc35
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ public MappingMetaData getMapping(String index, String type) {
logger.error(e.getMessage(), e);
return null;
}
mappingMetaData = mappings.get(index).get(type);

//通过别名查询mapping返回的是真实索引名称,mappings.get(index)返回null,为兼容别名情况修改如下:
ImmutableOpenMap<String, MappingMetaData> esIndex = mappings.get(index);
if(esIndex == null){
esIndex = mappings.valuesIt().next();
}
mappingMetaData = esIndex.get(type);
}
return mappingMetaData;
}
Expand Down

0 comments on commit e48bc35

Please sign in to comment.