Expand my Community achievements bar.

SOLVED

How to retrieve all metadata fields with specific prefix from all schemas using a single endpoint?

Avatar

Level 2

Hi community,

I need to retrieve all metadata fields that start with a specific prefix (e.g., nameMetadata_) from all metadata schemas in AEM.

Current situation:

I'm currently using this endpoint to get fields from a specific schema:

{{Instance}}/conf/global/settings/dam/adminui-extension/metadataschema/default.infinity.json

With a script, I can process the JSON and filter the metadata fields I need, but this endpoint only points to the default schema.

 

What I've tried:

I know I can use:

/conf/global/settings/dam/adminui-extension/metadataschema.infinity.json

This endpoint returns all schemas, but it requires iterating through each one and querying their fields individually.

My question:

Is there a more direct endpoint or method that allows me to:

  1. Retrieve in a single JSON all metadata fields from all schemas (even those not currently in use)?
  2. Or alternatively, is there a way to filter directly by field name (e.g., nameMetadata_*) through a query parameter or selector?

Basically, I'm looking to optimize the process and avoid having to make multiple server calls iterating schema by schema.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @EstebanTr,

Unfortunately, AEM does not provide a single endpoint that returns every metadata field across every metadata schema in one JSON.
And there is no built-in selector or query parameter that filters fields by name (e.g., nameMetadata_*) at /conf nodes.

You might want to explore these options:

1. Make one call: .infinity.json and parse locally

/conf/global/settings/dam/adminui-extension/metadataschema.infinity.json

This returns the entire schema tree.

  • Only 1 server call
  • Contains all fields of all schemas
  • You can recursively scan /items/* nodes and pick fields with your prefix
  • Fastest + most efficient approach

This is the recommended method.

2. Use QueryBuilder/Groovy Script Console

Run a script under /conf to scan all schemas:

Example Groovy:

def root = resourceResolver.getResource("/conf/global/settings/dam/adminui-extension/metadataschema")
root.listChildren().each { schema ->
    schema.adaptTo(Node).recurse { node ->
        node.getProperties().each { p ->
            if (p.name.startsWith("nameMetadata_")) {
                println("${node.path} -> ${p.name}")
            }
        }
    }
}

This avoids client-side looping, but still requires recursion.

3. Create a custom endpoint (Servlet / Sling Model Exporter)

If you need a “single JSON output,” you can create a custom servlet:

/bin/metadata-fields?prefix=nameMetadata_

Your servlet walks the /conf tree and returns exactly what you want.


Santosh Sai

AEM BlogsLinkedIn


View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @EstebanTr,

Unfortunately, AEM does not provide a single endpoint that returns every metadata field across every metadata schema in one JSON.
And there is no built-in selector or query parameter that filters fields by name (e.g., nameMetadata_*) at /conf nodes.

You might want to explore these options:

1. Make one call: .infinity.json and parse locally

/conf/global/settings/dam/adminui-extension/metadataschema.infinity.json

This returns the entire schema tree.

  • Only 1 server call
  • Contains all fields of all schemas
  • You can recursively scan /items/* nodes and pick fields with your prefix
  • Fastest + most efficient approach

This is the recommended method.

2. Use QueryBuilder/Groovy Script Console

Run a script under /conf to scan all schemas:

Example Groovy:

def root = resourceResolver.getResource("/conf/global/settings/dam/adminui-extension/metadataschema")
root.listChildren().each { schema ->
    schema.adaptTo(Node).recurse { node ->
        node.getProperties().each { p ->
            if (p.name.startsWith("nameMetadata_")) {
                println("${node.path} -> ${p.name}")
            }
        }
    }
}

This avoids client-side looping, but still requires recursion.

3. Create a custom endpoint (Servlet / Sling Model Exporter)

If you need a “single JSON output,” you can create a custom servlet:

/bin/metadata-fields?prefix=nameMetadata_

Your servlet walks the /conf tree and returns exactly what you want.


Santosh Sai

AEM BlogsLinkedIn