Overwriting Record in Logstash Using document_id?

I have data in which every record comes a three-time with attached unique referencedID. I am using document_id=>"referencedID". Currently, It is overwriting the record comes seconds time but It is not overwriting the record when it comes the third type which is my final record that I want to save in ELK.
Any way to overwrite that record third type. I am using the 7.2.0 version of the ELK stack?