该索引具有使用 Python 编写自定义脚本的功能,但我在任何地方都找不到使用 Python 编写的自定义脚本的示例。有人有工作脚本的例子吗?像 if 语句这样简单的东西会很棒。
请您参考如下方法:
使用 python 的简单自定义评分查询(假设您安装了插件)。
{
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"function_score": {
"query": {
"match_all": {}
},
"script_score": {
"lang": "python",
"script": [
"if _score:",
" _score"
]
},
"boost_mode": "replace"
}
},
"track_scores": true
}
