Adding new element to list of objects with the new name of field

I am trying to add new object to list of object in an elastic search index with java HighLevelRestClient. I know I can do it with following query:

String query = "ctx._source.custom_analysis.custom_analysis_list.add(params.custom_properties)";

This script adds a new value to the list but does not create object in index named 'custom_properties'

But I want the output similar to following where in a new field name (custom_properties ) is added as well is added to the index while I add a new object to arraylist.

"custom_analysis" : {
            "custom_analysis_list" : [
              {
                "custom_properties" : {
                  "deleted" : true,
                  "name" : "Custom Analysis1",
                  "description" : "Custom analysis for yogurt ",
                  "last_modified_date" : "01-08-2020",
                  "id" : "1",
                  "creation_date" : "01-08-2020",
                  "show_on_screen" : false,
                  "type" : "yogurt_us"
                }
              },
              {
                "custom_properties" : {
                  "deleted" : false,
                  "name" : "Custom Analysis2",
                  "description" : "Custom analysis description ",
                  "last_modified_date" : "01-01-2020",
                  "id" : "2",
                  "creation_date" : "01-01-2020",
                  "show_on_screen" : false,
                  "type" : "yogurt_us"
                }
              }] 
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.