gpt4 book ai didi

elasticsearch - script_score查询不支持[源代码]

转载 作者:行者123 更新时间:2023-12-02 22:56:45 27 4
gpt4 key购买 nike

我正在使用Elasticsearch OSS的官方Docker镜像(docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4),似乎完全无法使用script_score。似乎未启用脚本。

例如,这:
POST http://localhost:9200/address/address/_search

{
"query": {
"function_score": {
"query": {
"match": {
"fullAddress": {
"query": "13 fake",
"operator": "and"
}
}
},
"script_score": {
"lang": "expression",
"source": "doc['flatNumber'].length"
}
}
}
}

给我这个:

{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "script_score query does not support [source]",
"line": 13,
"col": 15
}
],
"type": "parsing_exception",
"reason": "script_score query does not support [source]",
"line": 13,
"col": 15
},
"status": 400
}

我尝试启用它:
PUT http://localhost:9200/_cluster/settings
{
"persistent": {
"script.engine.groovy.inline.aggs": "on"
}
}

但无济于事:

{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "persistent setting [script.engine.groovy.inline.aggs], not recognized"
}
],
"type": "illegal_argument_exception",
"reason": "persistent setting [script.engine.groovy.inline.aggs], not recognized"
},
"status": 400
}

如何获得 script_score

最佳答案

您只是在script中缺少script_score部分。像这样修改它,它将起作用:

    "script_score": {
"script": {
"lang": "expression",
"source": "doc['flatNumber'].length"
}
}

关于elasticsearch - script_score查询不支持[源代码],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50969666/

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