'Looks up an object with the given kwargs, creating one if necessary.
Returns a tuple of (object, created), where created is a boolean
specifying whether an object was created.'

def get_or_create(self, **kwargs):

    assert kwargs, 'get_or_create()    must    be    passed    at    least    one    keyword    argument'
    defaults = kwargs.pop('defaults', {})
    lookup = kwargs.copy()
    try:
        return (self.get(**lookup), False)
    except self.model.DoesNotExist:
        params = dict([(k, v) for (k, v) in kwargs.items() if ('__' not in k)])
        params.update(defaults)
        obj = self.model(**params)
        meta = obj.get_meta()
        meta.connection = get_es_connection(self.es_url, self.es_kwargs)
        meta.index = self.index
        meta.type = self.type
        obj.save(force=True)
        return (obj, True)
