def prefix_index(app, index):
    """Prefixes the given index if needed.

    :param app: Flask app to get the config from.
    :param index: Name of the index to prefix.
    :returns: A string with the new index name prefixed if needed.
    """
    index_prefix = app.config['SEARCH_INDEX_PREFIX'] or ''
    return index_prefix + index