elasticsearch - Elasticsearch:如何将十六进制字符串作为数字类型(整数或长整数)摄取?
问题描述
我在这里看到https://github.com/elastic/elasticsearch/pull/32213,Elasticsearch 添加了对 7.0.0 版本的长或整数类型的十六进制字符串摄取的支持并向前发展。
但是当我使用我的 Elasticsearch 7.3 并将类型设置为“整数”或“长”,然后尝试索引“0x1234”的值时,我得到一个错误[1]。
[1] 这是来自 python:
RequestError: RequestError(400, u'mapper_parsing_exception', u'failed to parse field [KEYWORD] of type [long] in document with id '#############'。预览字段值: 0x1234'")
Elasticsearch:如何将十六进制字符串作为数字类型(整数或长整数)摄取?
也许有某种配置值可以打开此功能......但我在文档中找不到任何内容。
解决方案
您引用的 PR 涉及摄取管道 - 一组工具,可帮助在将文档值插入 ES之前准备文档值。
但是很好,你已经提到了——convert
处理器是一个合适的解决方案:
- 存储将字段的字符串内容转换为的
KEYWORD
管道long
:
PUT _ingest/pipeline/hex-converter
{
"description": "converts the content of the KEYWORD field to a long",
"processors" : [
{
"convert" : {
"field" : "KEYWORD",
"type": "long"
}
}
]
}
- 在插入文档时使用此管道:
POST myindex/_doc?pipeline=hex-converter
{
"KEYWORD": "0x1234"
}
- 验证它是否有效——我们预计结果为 4660:
POST myindex/_search
推荐阅读
- javascript - 如何从项目列表中过滤掉
- java - Java JPanel 清除图形
- c# - for循环中双精度数组的索引超出范围
- java - 无法将 Spring Cloud Contract 测试的 RestAssured 的 RQ/RS 附加到 Allure 报告
- node.js - Express req.cookie 未定义
- c# - 在包含嵌套对象的大对象上使用 c# lambda GroupBy 时遇到问题
- r - FasttextR 编码
- css - 如何将 div 内的按钮向右移动并保持对齐?
- python - 脚注/注释与 xlabel 重叠
- identityserver4 - /connect/userinfo 返回了哪些声明?