Skip to content

Remove duplicate classifications in documents.0025

Just add a runsql with:

delete from documents_classification where id in (
  select id from (select c.id, row_number() over (partition by x.element_id order by c.confidence desc) as nb 
  from (
    select element_id, ml_class_id
    from documents_classification
    group by element_id, ml_class_id having count(id) > 1
  ) as x 
  inner join documents_classification as c on (c.element_id = x.element_id and c.ml_class_id = x.ml_class_id)
) as y where y.nb > 1);