Hi,
Apologies, I thought it should be same for any text field. I have provided the details below.
I use the exact same query posted in the question
Document
{
"deviceid" : "XX12",
"time" : "2020-02-20T00:00:00.000Z",
"severity" : "notice",
"log" : "[system current time] : Thu Feb 20 00:00:00 UTC 2020",
}
Mapping
Summary
{
"logdata" : {
"mappings" : {
"loginfo" : {
"properties" : {
"deviceid" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"log" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"severity" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"time" : {
"type" : "date"
}
}
}
}
}
}
Error message
Summary
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"_source['log'].va ...",
"^---- HERE"
],
"script": "_source['log'].value.length() > 10",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "logdata",
"node": "xxxxxxxxxxxxxx",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: {\n "bool" : {\n "filter" : [\n {\n "script" : {\n "script" : {\n "source" : "_source['log'].value.length() > 10",\n "lang" : "painless"\n },\n "boost" : 1.0\n }\n }\n ],\n "adjust_pure_negative" : true,\n "boost" : 1.0\n }\n}",
"index_uuid": "index_uuid",
"index": "logdata",
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"_source['log'].va ...",
"^---- HERE"
],
"script": "_source['log'].value.length() > 10",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Variable [_source] is not defined."
}
}
}
}
],
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"_source['log'].va ...",
"^---- HERE"
],
"script": "_source['log'].value.length() > 10",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Variable [_source] is not defined."
}
}
},
"status": 400
}