Formatting Enriched field in Java

Hello,

I have implemented an enrich processor and I am trying to properly format the enrich index’s docs. For example, I have a source index with a nationality and an average height. I want to enrich an index that only contains nationality data with the average height data from the source index. What is currently happening is that in the enrich index, an object of both nationality and height data is set into the “height” data field. Instead of this, I want to format it so only the true height data is set to the “height” field of the enrich data. (Ex “height” : “5.11” instead of “height” : { “nationality” : “…..”, “height” : “5.11” } ). This is all being done in Java. I am wondering if this is possible or if the limitations of the enrich processor makes this unattainable. Thanks!

You could then add a rename processor to rename the height.height field to height.

Hello Again,

Thanks for sending in a reply to my question.
I have been trying to implement the rename processor with no success. Here is my implementation in java:

Processor renameProcessor = new Processor.Builder()
	            .rename(r -> r
	                .field("height.height")
	                .targetField("height")
	                .ignoreMissing(true)
	                .ignoreFailure(true))
	            .build();

But the outcome is still not a flat height field. I am creating a pipeline via a PutPipelineRequest object and i specify when i would like my processor to be executed in this declaration, the order is enrichProcessor, scriptProcessor, removeProcessor, renameProcessor. I have tried switching the order with no success. Is there another Processor/alternate implementation that can aid me to accomplish my goal?

Could you share a full example using the simulate API from the dev console?
So we can better understand what your problem is.

Hello Again,

Sorry for the late response. Here is some info that will hopefully help you better understand my problem. Here is a simplified example on what mine looks like.

 "_index" : "male_heights",
        "_id" : "German|5.11_M",
        "_score" : 1.0,
        "_source" : {
          "nationality" : "German",
          "height" : {
            "height" : "5.11"
          },
          "gender" : "M",
        }

But i need it to look like this.

"_index" : "male_heights",
        "_id" : "German|5.11_M",
        "_score" : 1.0,
        "_source" : {
          "nationality" : "German",
           "height" : "5.11",
          "gender" : "M",
        }

Please let me know if you need anymore information. Thanks for your help!

What does not work with what I proposed here?

Could you share a full simulate call?