Metadata Examples

If you want to process both standardized and non-standardized metadata elements, you can loop through a KVMetadataList without checking the eKey member – both standardized and non-standardized metadata can be handled in the same way.

However, standardization allows you to handle particular metadata fields differently. Below are some illustrative examples of ways you might use standardized fields to act on documents.

// Ignore non-standardized fields
if(element->eKey == KVMetadataKey_Other)
{
    continue;
}		
// Ignore small images
if(element->eKey == KVMetadataKey_ImageWidth)
{
    int64_t width = *(int64_t*)element->pValue;
    if(width < 200)
    {
        break;
    }
}
// Search for documents created by a certain company
if(element->eKey == KVMetadataKey_Company)
{
    KV_String company = *(KV_String*)element->pValue;
    if(strncmp("OpenText", company.pcString, company.cbSize) == 0)
    {
        return pathToInputFile;
    }
}		
// Find all documents created since the beginning of 2022
if(element->eKey == KVMetadataKey_Created)
{
    int64_t created = *(int64_t*)element->pValue;
    //2022-01-01 00:00:00 UTC in Windows File Time
    if(created > 132854688000000000)
    {
        return pathToInputFile;
    }
}

Handle Duplicate Metadata Elements

The following example demonstrates how to take advantage of field standardization, but also avoid processing a metadata field more than once.

// Process standardized elements where possible but also process
// non-standard elements that have no standardized alternative.
// Ignore duplicate elements output by KeyView for backwards compatibility.

if(!element->bHasStandardAlternative && !element->bIsSuperseded)
{
    process(element);
}