Closed
Description
I'm trying to save Response
object in redis cache in django project
from django.core.cache import cache
query = \
{
"query": {
# some query here
}
}
searcher = Search(using=haystack_connections['default'].get_backend().conn)
searcher = searcher.update_from_dict(query)[:10]
results = searcher.execute()
cache.set('foo', result, timeout=60*60)
cache.get('foo')
/home/gnom/www/env/apps/elasticsearch_dsl2/result.pyc in __repr__(self)
24
25 def __repr__(self):
---> 26 return '<Response: %r>' % self.hits
27
28 def __len__(self):
/home/gnom/www/env/apps/elasticsearch_dsl2/result.pyc in hits(self)
47 except AttributeError as e:
48 # avoid raising AttributeError since it will be hidden by the property
---> 49 raise TypeError("Could not parse hits.", e)
50
51 # avoid assigning _hits into self._d_
TypeError: ('Could not parse hits.', AttributeError(u"'Response' object has no attribute '_callbacks'",))
or:
cache.set('foo', list(result), timeout=60*60)
cache.get('foo')
/home/gnom/www/env/apps/elasticsearch_dsl2/result.pyc in <genexpr>((key,))
83 return '<Result(%s): %s>' % (
84 '/'.join(getattr(self.meta, key) for key in
---> 85 ('index', 'doc_type', 'id') if key in self.meta),
86 super(Result, self).__repr__()
87 )
/home/gnom/www/env/apps/elasticsearch_dsl2/utils.pyc in __getattr__(self, attr_name)
121 except KeyError:
122 raise AttributeError(
--> 123 '%r object has no attribute %r' % (self.__class__.__name__, attr_name))
124
125 def __delattr__(self, attr_name):
AttributeError: 'Result' object has no attribute 'meta'
dsl lib version is (2, 2, 0)