Plugins
Dedupe

Dedupe

Find duplicate documents in any collection and merge a group of them into one from the admin.

@10x-media/dedupe finds documents that are probably the same thing and merges a group of them into one.

payload.config.ts
import { buildConfig } from 'payload'
import { dedupe } from '@10x-media/dedupe'

export default buildConfig({
  plugins: [
    dedupe({
      collections: {
        customers: {
          match: {
            fields: [
              { path: 'email', weight: 45 },
              { path: 'name', weight: 40, compare: 'text' },
              { path: 'phone', weight: 35, compare: 'phone' },
            ],
          },
        },
      },
    }),
  ],
})

Run payload generate:importmap afterwards.

Search and merge

Search compares documents that share a key and keeps the likely duplicates in a queue. It runs on every save and as a scan.

Merge shows a group of documents side by side, lets the reviewer pick the primary and a value per field, and writes the result.

They work independently: customers: true gives a collection the merge screen without search.

Where things are

  • /admin/dedupe: the queue of look-alike groups. Its search bar keeps the groups with a document that the collection's own list search finds: the fields in admin.listSearchableFields, or the useAsTitle field.
  • /admin/dedupe/merge: the merge screen.
  • "Merge selected" in the list view menu of a configured collection.

The plugin adds no link to its views to the admin's sidebar: place one where your editors need it, with admin.components.afterNavLinks.

The plugin keeps its data in hidden collections: dedupe-pairs and, with the built-in adapter, dedupe-keys. It keeps no record of a merge: to keep one, write it on hooks.beforeRemove.

On this page