Java query from shell script

I will not answer directly to your question.

Here is what I do with pipelines and queries.

  1. I do not used the builders.
  2. I keep them in a resource file as a json document.
  3. I load them at run time.
  4. I use Document.parse() and then use the usual collection API.

This way

  1. I can change a pipeline or query without recompiling.
  2. I can debug the pipeline with the shell or compass.
  3. Store back the result in my resource file.