I upgraded my ES from 2.1 to 7.10, when I tried to use the same query way to search, it always show
{
"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
}
Old query string:
{
"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"
}
}
}
New query string:
{
"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"
]
}
}
Actually I'm not sure if combined-conversion-scorer is custom script or not, I can't find it on old version by GET _scripts/combined-conversion-scorer. How can I update my script to let it works? Thank you
CodePudding user response:
native
scripts are actually compiled Java classes bundled as plugins.
So you need to look for a JAR in your plugins folder. If you have the source files then you're good otherwise you might have to decompile it. In the end, you'll need to recompile and rebuild the plugin for your new ES version... or simply reimplement it in Painless.