Commands: Documents: How to Get Document Metadata Only

GetDocumentsCommand can be used to retrieve the metadata of documents.

Syntax

public GetDocumentsCommand(String id, String[] includes, boolean metadataOnly)
public GetDocumentsCommand(String[] ids, String[] includes, boolean metadataOnly)
Parameters
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.

Example

GetDocumentsCommand command = new GetDocumentsCommand("orders/1-A", null, true);
session.advanced().getRequestExecutor().execute(command);

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 = fieldIterator.next();
    JsonNode value = documentMetadata.get(field);
    System.out.println(field + " = " + value);
}