Trim all text fields

Hi,
I would like all saved text fields to be trimmed, for all indexes, such that the leading and end spaces will be removed.
I am using Java API for indexing documents etc.

Not sure how to use the ingest processors, and in any case, I would not like to specify each field in the configured processor.

As for analyzers, this is an option, but would like then to allow for taking an existing analyzer, and "inheriting" it, by only changing the behavior to remove the leading and end spaces.

Any suggestions?