Accessing field values in script processor

Hi, I'm studding for the ECE and when reading about script processors to be used in ingestion pipelines I see in the documentation that in order to access the field value I should use the ctx variables

You can access the current ingest document from within the script context by using the ctx variable.

I've tried to use doc values but I've compilation errors, I've tried to access to ctx._source and I have runtime errors

My question is why the only way to access fields is using ctx. variable

Thank you!
Regards
Ana