通过ES索引别名获取mapping,返回数据为真实索引,而不是别名,导致mappings.get(index).get(type)报空指针异常 #4122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
bug fix #4121 通过ES索引别名获取maping后mappings.get(index).get(type)空指针异常
问题复现:
返回结果中索引名order_pos_2022.03-000011为真正的索引。
2. 当执行mappings.get(index).get(type)代码时,入参index为配置的别名order_pos,mappings.get(order_pos)返回null
3. 引起NullPointException异常
处理办法:
因为是写入数据,通过索引获取mapping只能有1个mapping数据,取到即可: