there is a error when using the query below:
GET trxdetail-fj/_search
{
"query": {
"script": {
"script": {
"source": "doc['OPPACC'].length()>10",
"lang": "painless"
}
}
}
}
errror message:
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: {\n "script" : {\n "script" : {\n "source" : "doc['OPPACC'].length()>10",\n "lang" : "painless"\n },\n "boost" : 1.0\n }\n}",
"index_uuid": "n1UUebJaT7WJiomMDjbCXw",
"index": "trxdetail-fj"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "trxdetail-fj",
"node": "KNkvY1LsSQ-VA61GpNNWkA",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: {\n "script" : {\n "script" : {\n "source" : "doc['OPPACC'].length()>10",\n "lang" : "painless"\n },\n "boost" : 1.0\n }\n}",
"index_uuid": "n1UUebJaT7WJiomMDjbCXw",
"index": "trxdetail-fj",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "cannot execute scripts using [filter] context"
}
}
}
]
},
"status": 400
}
and my config is :
# ---------------------------------- script ----------------------------------- script.allowed_types: inline script.allowed_contexts: search,update,aggs
finally, i want to search in my index to find some record which is ending with '99' and the length of field is 12.
for example, one of records is "347897109899" in the field naming "oppacc" which match the condition.
how to do it ?