diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 31ed7d0..831e23d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,11 @@ CHANGELOG ========= +0.8.2 +----- + +* When subclassing ``SolrQuerySet``, result documents can now be customized by extending ``get_result_document`` + 0.8.1 ----- * Exclude proxy models when collecting indexable subclasses diff --git a/parasolr/__init__.py b/parasolr/__init__.py index 86253f1..9528ed6 100644 --- a/parasolr/__init__.py +++ b/parasolr/__init__.py @@ -1,6 +1,6 @@ default_app_config = "parasolr.apps.ParasolConfig" -__version_info__ = (0, 8, 1, None) +__version_info__ = (0, 8, 2, None) # Dot-connect all but the last. Last is dash-connected if not None. __version__ = ".".join([str(i) for i in __version_info__[:-1]]) diff --git a/parasolr/query/queryset.py b/parasolr/query/queryset.py index 85a2476..1507c91 100644 --- a/parasolr/query/queryset.py +++ b/parasolr/query/queryset.py @@ -68,7 +68,6 @@ def get_results(self, **kwargs) -> List[dict]: Returns: Solr response documents as a list of dictionaries. """ - # TODO: can we store the result cache and only retrieve # if query options have changed? # For now, always query. @@ -83,9 +82,14 @@ def get_results(self, **kwargs) -> List[dict]: self._result_cache = self.solr.query(**query_opts) # if there is a query error, result will not be set if self._result_cache: - return [doc.as_dict() for doc in self._result_cache.docs] + return [self.get_result_document(doc) for doc in self._result_cache.docs] return [] + def get_result_document(self, doc): + """Method to transform document results. Default behavior is to + convert from attrdict to dict.""" + return doc.as_dict() + def _set_highlighting_opts(self, query_opts: Dict) -> None: """Configure highlighting attributes on query_opts. Modifies dictionary directly."""