TL:DR After an awful update of physical RFID readers, a connected manufactory started to generate histories in a continious mode instead of a sequential mode This lead to hundreds of thousands duplicates in the history database With one Elasticsearch aggregation and one small Rails script, it was easy to clean up both elasticsearch and Postgre database Management of Histories with Elasticsearch In this project, we use The Audit gem of Ruby on Rails to track any change on the main…