Commands: Documents: How to Get Document Metadata Only

GetDocumentsCommand can be used to retrieve the metadata of documents.


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


var command = new GetDocumentsCommand("orders/1-A", null, metadataOnly: true);
session.Advanced.RequestExecutor.Execute(command, session.Advanced.Context);
var result = (BlittableJsonReaderObject)command.Result.Results[0];
var documentMetadata = (BlittableJsonReaderObject)result["@metadata"];

// Print out all the metadata properties.
foreach (var propertyName in documentMetadata.GetPropertyNames())
    documentMetadata.TryGet<object>(propertyName, out var metaPropValue);
    Console.WriteLine("{0} = {1}", propertyName, metaPropValue);