Rejecting Items

You have a Sitemap source in which you have configured web scraping to add a metadata field named section on your items. You write a pre-conversion indexing pipeline extension (IPE) to reject items whose section metadata value is internal.

def get_safe_meta_data(meta_data_name):
    safe_meta = ''
    meta_data_value = document.get_meta_data_value(meta_data_name)
    if meta_data_value:
        safe_meta = meta_data_value[-1]
    return safe_meta

section = get_safe_meta_data('section').lower()

if section == 'internal':
    log('REJECT: internal')
    document.reject()