Skip to content

Instantly share code, notes, and snippets.

@rococodogs
Created June 11, 2018 13:49
Show Gist options
  • Save rococodogs/5d4d346fffbfbc3ecb40cc8b16441556 to your computer and use it in GitHub Desktop.
Save rococodogs/5d4d346fffbfbc3ecb40cc8b16441556 to your computer and use it in GitHub Desktop.
dspace metadata field usage postgresql query

which metadata fields are being used by dspace?

SELECT
  element,
  qualifier,
  scope_note,
  count(*)
FROM metadatavalue
JOIN metadatafieldregistry 
  ON metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id
GROUP BY
  metadatafieldregistry.element,
  metadatafieldregistry.qualifier,
  metadatafieldregistry.scope_note
ORDER BY ELEMENT asc

if you're not concerned about the counts, you could simplify things by using a SELECT DISTINCT query and removing the GROUP BY block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment