ELasticsearch 5.4 Remove nested field

Hello. I have different types of fields in my index type:

{
"test_index": {
"mappings": {
"search_type": {
"properties": {
"keywords": {
"type": "keyword"
},
"person": {
"properties": {
"relation": {
"properties": {
"subject": {
"type": "nested",
"properties": {
"first": {
"type": "keyword"
}
},
"last": {
"type": "keyword"
}
}
}
}
}
}
}
},
"relation": {
"properties": {
"first": {
"type": "keyword"
}
},
"last": {
"type": "keyword"
}
}
}
}
}
}
}
}
}
}

I want to remove fields and I am using reindex, it works fine with simple field like 'keywords':

ReindexAction.INSTANCE.newRequestBuilder( m_transportClient )
.source( "test_index" )
.destination( "test_index_new" )
.script( new Script( "if (ctx._type=="search_type") { ctx._source.remove("keywords") }" ) ).get();

But how should I build the script if I want to delete:

  1. person.relation.subject.last (field from nested)
  2. person.relation.subject (nested field)
  3. relation.first (field from composite field)
  4. relation (composite field with it's children)

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