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':
    document.reject("Section metadata value is internal.")
Note

This example rejects matching items and surfaces a rejection reason in the rejected item’s message. Don’t use log() to record the rejection reason for this case, because rejected items don’t surface standard extension log output in the Log Browser. See Log messages from an indexing pipeline extension.