def expand_action(data):
        """
        From one document or action definition passed in by the user extract the
        action/data lines needed for elasticsearch's
        :meth:`~elasticsearch.Elasticsearch.bulk` api.
        :return es format to bulk doc
        """
        # when given a string, assume user wants to index raw json
        if isinstance(data, string_types):
            return '{"index": {}}', data

        # make sure we don't alter the action
        data = data.copy()
        op_type = data.pop(EsBulk.OP_TYPE, EsBulk.INDEX)

        action = ActionParser._get_relevant_action_params(data, op_type)

        # no data payload for delete
        if op_type == EsBulk.DELETE:
            return action, None

        return action, data.get(EsDocProperties.SOURCE, data)
From one document or action definition passed in by the user extract the
        action/data lines needed for elasticsearch's
        :meth:`~elasticsearch.Elasticsearch.bulk` api.
        :return es format to bulk doc