'Return bulk code'

def get_bulk(self, create=False):

    result = []
    op_type = 'index'
    if create:
        op_type = 'create'
    meta = self._meta
    cmd = {op_type: {'_index': meta.index, '_type': meta.type}}
    if meta.parent:
        cmd[op_type]['_parent'] = meta.parent
    if meta.version:
        cmd[op_type]['_version'] = meta.version
    if meta.id:
        cmd[op_type]['_id'] = meta.id
    result.append(json.dumps(cmd, cls=self._meta.connection.encoder))
    result.append('\n')
    result.append(json.dumps(self, cls=self._meta.connection.encoder))
    result.append('\n')
    return ''.join(result)
