script_score 不适用于 ElasticSearch 7
script_score not works on ElasticSearch 7
我把我的ES从2.1升级到7.10,当我尝试使用相同的查询方式搜索时,它总是显示
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "script_score: the script could not be loaded",
"index": "designs",
"index_uuid": "jqvLIrY2TIyJU2bdAsGgkQ"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "designs",
"node": "jkt6cdUBTKOJ_HTA83wgWQ",
"reason": {
"type": "query_shard_exception",
"reason": "script_score: the script could not be loaded",
"index": "designs",
"index_uuid": "jqvLIrY2TIyJU2bdAsGgkQ",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "script_lang not supported [native]"
}
}
}
]
},
"status": 400
}
旧查询字符串:
{
"from": 0,
"size": 20,
"explain": false,
"_source": {
"include": [
"designId",
"memberId",
"isPersonalizable",
"sellerTags",
"products.productId",
"products.productTypeId",
"products.imageOneId",
"products.imageTwoId",
"products.hasPersonalizableSvg",
"products.storeId"
]
},
"sort": [
{
"_score": {}
},
{
"designId": {
"order": "desc"
}
}
],
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": {
"inline": "combined-conversion-scorer",
"lang": "native",
"params": {
"query": "peanuts",
"productTypeIds": [
128,
134,
755,
96,
113,
1230,
1231
]
}
}
}
}
],
"query": {
"bool": {
"must": [
{
"multi_match": {
"type": "most_fields",
"query": "peanuts",
"minimum_should_match": "3<75%",
"fields": [
"sellerTags",
"sellerTags.shingles",
"sellerTags.stemmed",
"editorialTags",
"editorialTags.shingles",
"editorialTags.stemmed"
]
}
}
],
"filter": [
{
"bool": {
"must": [
{
"nested": {
"query": {
"terms": {
"products.productTypeId": [
128,
134,
755,
96,
113,
1230,
1231
]
}
},
"path": "products"
}
},
{
"nested": {
"query": {
"term": {
"products.locations": {
"value": "US-1"
}
}
},
"path": "products"
}
}
],
"must_not": [
{
"multi_match": {
"query": "some query",
"fields": [
"sellerTags",
"editorialTags"
]
}
}
]
}
}
]
}
},
"boost_mode": "multiply"
}
}
}
新查询字符串:
{
"explain": true,
"from": 0,
"query": {
"function_score": {
"boost_mode": "multiply",
"functions": [
{
"script_score": {
"script": {
"source": "combined-conversion-scorer",
"lang": "native",
"params": {
"query": "peanuts"
}
}
}
}
],
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"nested": {
"path": "products",
"query": {
"term": {
"products.locations": {
"value": "US-1"
}
}
}
}
}
],
"must_not": [
{
"multi_match": {
"fields": [
"sellerTags",
"editorialTags"
],
"query": "another query"
}
}
]
}
}
],
"must": [
{
"multi_match": {
"fields": [
"sellerTags",
"sellerTags.shingles",
"sellerTags.stemmed",
"editorialTags",
"editorialTags.shingles",
"editorialTags.stemmed"
],
"minimum_should_match": "3<75%",
"query": "peanuts",
"type": "most_fields"
}
}
]
}
}
}
},
"size": 200,
"sort": [
{
"_score": {}
},
{
"designId": {
"order": "desc"
}
}
],
"_source": {
"includes": [
"designId",
"memberId",
"isPersonalizable",
"sellerTags",
"products.productId",
"products.productTypeId",
"products.imageOneId",
"products.imageTwoId",
"products.hasPersonalizableSvg",
"products.storeId"
]
}
}
实际上我不确定 combined-conversion-scorer 是否是自定义脚本,我无法通过 GET _scripts/combined-conversion-scorer 在旧版本上找到它。
我怎样才能更新我的脚本让它工作?谢谢
native
scripts 实际上编译 Java 类 捆绑为插件。
因此您需要在插件文件夹中查找 JAR。如果你有源文件那么你就很好,否则你可能需要反编译它。最后,您需要 recompile and rebuild the plugin 为您的新 ES 版本...或者简单地在 Painless 中重新实现它。
我把我的ES从2.1升级到7.10,当我尝试使用相同的查询方式搜索时,它总是显示
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "script_score: the script could not be loaded",
"index": "designs",
"index_uuid": "jqvLIrY2TIyJU2bdAsGgkQ"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "designs",
"node": "jkt6cdUBTKOJ_HTA83wgWQ",
"reason": {
"type": "query_shard_exception",
"reason": "script_score: the script could not be loaded",
"index": "designs",
"index_uuid": "jqvLIrY2TIyJU2bdAsGgkQ",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "script_lang not supported [native]"
}
}
}
]
},
"status": 400
}
旧查询字符串:
{
"from": 0,
"size": 20,
"explain": false,
"_source": {
"include": [
"designId",
"memberId",
"isPersonalizable",
"sellerTags",
"products.productId",
"products.productTypeId",
"products.imageOneId",
"products.imageTwoId",
"products.hasPersonalizableSvg",
"products.storeId"
]
},
"sort": [
{
"_score": {}
},
{
"designId": {
"order": "desc"
}
}
],
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": {
"inline": "combined-conversion-scorer",
"lang": "native",
"params": {
"query": "peanuts",
"productTypeIds": [
128,
134,
755,
96,
113,
1230,
1231
]
}
}
}
}
],
"query": {
"bool": {
"must": [
{
"multi_match": {
"type": "most_fields",
"query": "peanuts",
"minimum_should_match": "3<75%",
"fields": [
"sellerTags",
"sellerTags.shingles",
"sellerTags.stemmed",
"editorialTags",
"editorialTags.shingles",
"editorialTags.stemmed"
]
}
}
],
"filter": [
{
"bool": {
"must": [
{
"nested": {
"query": {
"terms": {
"products.productTypeId": [
128,
134,
755,
96,
113,
1230,
1231
]
}
},
"path": "products"
}
},
{
"nested": {
"query": {
"term": {
"products.locations": {
"value": "US-1"
}
}
},
"path": "products"
}
}
],
"must_not": [
{
"multi_match": {
"query": "some query",
"fields": [
"sellerTags",
"editorialTags"
]
}
}
]
}
}
]
}
},
"boost_mode": "multiply"
}
}
}
新查询字符串:
{
"explain": true,
"from": 0,
"query": {
"function_score": {
"boost_mode": "multiply",
"functions": [
{
"script_score": {
"script": {
"source": "combined-conversion-scorer",
"lang": "native",
"params": {
"query": "peanuts"
}
}
}
}
],
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"nested": {
"path": "products",
"query": {
"term": {
"products.locations": {
"value": "US-1"
}
}
}
}
}
],
"must_not": [
{
"multi_match": {
"fields": [
"sellerTags",
"editorialTags"
],
"query": "another query"
}
}
]
}
}
],
"must": [
{
"multi_match": {
"fields": [
"sellerTags",
"sellerTags.shingles",
"sellerTags.stemmed",
"editorialTags",
"editorialTags.shingles",
"editorialTags.stemmed"
],
"minimum_should_match": "3<75%",
"query": "peanuts",
"type": "most_fields"
}
}
]
}
}
}
},
"size": 200,
"sort": [
{
"_score": {}
},
{
"designId": {
"order": "desc"
}
}
],
"_source": {
"includes": [
"designId",
"memberId",
"isPersonalizable",
"sellerTags",
"products.productId",
"products.productTypeId",
"products.imageOneId",
"products.imageTwoId",
"products.hasPersonalizableSvg",
"products.storeId"
]
}
}
实际上我不确定 combined-conversion-scorer 是否是自定义脚本,我无法通过 GET _scripts/combined-conversion-scorer 在旧版本上找到它。 我怎样才能更新我的脚本让它工作?谢谢
native
scripts 实际上编译 Java 类 捆绑为插件。
因此您需要在插件文件夹中查找 JAR。如果你有源文件那么你就很好,否则你可能需要反编译它。最后,您需要 recompile and rebuild the plugin 为您的新 ES 版本...或者简单地在 Painless 中重新实现它。