elasticsearch-dsl-py icon indicating copy to clipboard operation
elasticsearch-dsl-py copied to clipboard

Processors DSL

Open gegen07 opened this issue 5 years ago • 3 comments
trafficstars

Is there a solution to DSL for processors? Using low-client to create dynamic processors hurts a lot, a mess of kwargs and if/else.

gegen07 avatar Apr 06 '20 21:04 gegen07

@sethmlarson Any plans to add IngestClient to DSL package?

gegen07 avatar Feb 25 '22 18:02 gegen07

Not currently, what parts of the ingest pipeline are tough to use and warrant a declarative structure?

sethmlarson avatar Feb 28 '22 17:02 sethmlarson

I was using the enrich processor, but the enrichment process could support an array of objects or a simple JSON object. So, I wrote two repetitive blocks of code like these ones below:

For the array of objects:

self._json = {
  "description": description,
  "processors": [
      {
          "foreach": {
              "field": kwargs.get("field_array"),
              "processor": {
                  "enrich": {
                      "policy_name": policy_name,
                      "field": "_ingest._value." + match_field,
                      "target_field": "_ingest._value."
                      + target_field_name,
                      "ignore_missing": True,
                  }
              },
              "ignore_failure": True,
          }
      }
  ],
}

For simple JSON objects:

self._json = {
    "description": description,
    "processors": [
        {
            "enrich": {
                "policy_name": policy_name,
                "field": match_field,
                "target_field": target_field_name,
                "ignore_missing": True,
            }
        }
    ],
}

For the remove_field processor, I have to do the same copy and change minimal pieces with the same previous logic.

Sometimes there's some adjustment that I could do to be more generic but I didn't think of another manner to do it.

gegen07 avatar Feb 28 '22 19:02 gegen07

I'm also looking for pipeline settings support and found nothing in the documentation.

thedeadliestcatch avatar Feb 19 '24 11:02 thedeadliestcatch