gpt4 book ai didi

elasticsearch - 如何通过使用Painless拒绝来自Elasticsearch索引结果中json数据类型列的值?

转载 作者:行者123 更新时间:2023-12-03 00:48:14 24 4
gpt4 key购买 nike

我的问题确实很简单而且很独特。我正在尝试从Elasticsearch索引中的json字符串列获取值。
如何从下面的数据中获取“ClassName”?

我的行是:
enter image description here

{
"ClassName": "System.InvalidOperationException",
"Message": "Sequence contains no elements",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " . . . . .
}

我的解决方案是

GET slog-2019-08-11/_search
{
"script_fields": {
"data": {
"script": {
"lang": "expression",
"source": "doc['ClassName']",
"params": {
"markup": 0.2
}
}
}
}
}

但是它给我返回了一个错误:

{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "link error",
"script_stack": [
"doc['ClassName']",
" ^---- HERE"
],
"script": "doc['ClassName']",
"lang": "expression"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "slog-2019-08-11",
"node": "TBSUPCkhQ1aHX069zwT7Tg",
"reason": {
"type": "script_exception",
"reason": "link error",
"script_stack": [
"doc['ClassName']",
" ^---- HERE"
],
"script": "doc['ClassName']",
"lang": "expression",
"caused_by": {
"type": "parse_exception",
"reason": "Field [ClassName] does not exist in mappings"
}
}
}
]
},
"status": 500
}

最佳答案

您是否尝试过这种语法?:

"source": "doc['ClassName'].value",

关于elasticsearch - 如何通过使用Painless拒绝来自Elasticsearch索引结果中json数据类型列的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57603300/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com