Elasticsearch keyword not generated

I have Elasticsearch entry with text field value as

14-Apr-2023 20:44:46.693 INFO [pool-2-thread-24] com.xyz.log [app_id:uuid] calling execute-task with url=https://example.com/api/applications/uuid/tasks/TASK_NAME/execute/, body=workflow_id=uuid variables={	

I'm trying to generate scripted field from this. my script looks like below

if(doc.containsKey('log') ) {
    if (doc.containsKey('log.keyword')) {
            return "doc[<field>].size()==0"
        else { return doc['log.keyword'].value; }
    else { return "!doc.containsKey('log.keyword')"; }
} else { return "!doc.containsKey('log')"; }

I'm getting evaluated value as doc[<field>].size()==0. for some other values I'm able to extract correct value i.e. pool-2-thread-24

Can someone help me identifying issue please.
Why is doc.containsKey('log.keyword') but doc['log.keyword'].size() zero?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.