-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Closed
Labels
Feature:SearchQuerying infrastructure in KibanaQuerying infrastructure in KibanabugFixes for quality problems that affect the customer experienceFixes for quality problems that affect the customer experience
Description
Kibana version:
7.5 and 7.8
Describe the bug:
Sorting a string type scripted field in discover throws an error.
Steps to reproduce:
- Add any sample data set
- Add a
stringtype scripted field. Something simple like...
return 'Testing';
- Go to discover
- Add the scripted field to the Selected fields
- Try sorting the scripted field column
Expected behavior:
Sorting of scripted string fields
Errors in browser console (if relevant):
search_phase_execution_exception
all shards failed
Error: Bad Request
at Fetch.fetchResponse (http://localhost:5601/zhv/9007199254740991/bundles/core/core.entry.js:57468:13)
at async interceptResponse (http://localhost:5601/zhv/9007199254740991/bundles/core/core.entry.js:57880:10)
at async http://localhost:5601/zhv/9007199254740991/bundles/core/core.entry.js:57366:39
Provide logs and/or server output (if relevant):
ES request error
"root_cause" : [
{
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"return 'Testing';",
" ^---- HERE"
],
"script" : "return 'Testing';",
"lang" : "painless",
"position" : {
"offset" : 7,
"start" : 0,
"end" : 17
}
}
],Any additional context:
The discovered request appears to be setting the wrong type (i.e. number) for the scripted field which is causing the error. When changed to the correct type (i.e. string), the request is successful.
GET test/_search
{
"version": true,
"size": 500,
"sort": [
{
"_score": {
"order": "desc"
}
},
{
"_script": {
"script": {
"source": "return 'Testing';",
"lang": "painless"
},
- "type": "number",
+ "type": "string",
"order": "desc"
}
}
],
"stored_fields": [
"*"
],
"script_fields": {
"scriptTest": {
"script": {
"source": "if ( doc['prediction'].value == 3) {\nreturn 'High';\n} else {\nreturn 'Information Only';\n}",
"lang": "painless"
}
},
"myField": {
"script": {
"source": "return 'Testing';",
"lang": "painless"
}
}
},
"docvalue_fields": [],
"_source": {
"excludes": []
},
"query": {
"bool": {
"must": [],
"filter": [
{
"match_all": {}
}
],
"should": [],
"must_not": []
}
},
"highlight": {
"pre_tags": [
"@kibana-highlighted-field@"
],
"post_tags": [
"@/kibana-highlighted-field@"
],
"fields": {
"*": {}
},
"fragment_size": 2147483647
}
}edmarmoretti
Metadata
Metadata
Assignees
Labels
Feature:SearchQuerying infrastructure in KibanaQuerying infrastructure in KibanabugFixes for quality problems that affect the customer experienceFixes for quality problems that affect the customer experience
