Commands: Documents: How to Get Document Metadata Only

GetDocumentsCommand can be used to retrieve the metadata of documents.


public GetDocumentsCommand(String id, String[] includes, boolean metadataOnly)
public GetDocumentsCommand(String[] ids, String[] includes, boolean metadataOnly)
id / ids String / String[] IDs of documents to get metadata for
includes String Related documents to fetch along with the document
metadataOnly boolean Whether to fetch the whole document or just the metadata.


GetDocumentsCommand command = new GetDocumentsCommand("orders/1-A", null, true);

JsonNode result = command.getResult().getResults().get(0);
ObjectNode documentMetadata = (ObjectNode) result.get("@metadata");

// Print out all the metadata properties.
Iterator<String> fieldIterator = documentMetadata.fieldNames();

while (fieldIterator.hasNext()) {
    String field =;
    JsonNode value = documentMetadata.get(field);
    System.out.println(field + " = " + value);