def get_index_action(index_name, document_type, document):
    """Generate index action for a given document.

    :param index_name: Elasticsearch index to use
    :type index_name: str
    :param document_type: Elasticsearch document type to use
    :type index_name: str
    :param document: Document to be indexed
    :type row: dict
    :return: Action to be passed in bulk request
    :rtype: dict

    """
    action = {
        '_index': index_name,
        '_type': document_type,
        '_source': document,
    }

    # Use the same _id field in elasticsearch as in the database table
    if '_id' in document:
        action['_id'] = document['_id']

    return action