-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
facets: provide CombinedTermsFacet to fix #798 [+] #549
facets: provide CombinedTermsFacet to fix #798 [+] #549
Conversation
e4b7d03
to
8a2d045
Compare
label=_('Resource types'), | ||
value_labels=VocabularyL10NLabels(current_service) | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just repeated docstring - cleaning up 🧹
@@ -149,7 +144,7 @@ def _parse_values(self, filter_values): | |||
.. code-block:: python | |||
|
|||
{ | |||
'publication': ['publication::book', 'publication::journal'], | |||
'publication': ['book', 'journal'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually what this function does.
@@ -246,6 +239,211 @@ def get_labelled_values( | |||
return ret_val | |||
|
|||
|
|||
class CombinedTermsFacet(NestedTermsFacet): | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best place to explain more complex things and reasoning behind approaches is in the code itself so I placed the explainer here.
def get_parents(self): | ||
"""Return parents. | ||
|
||
We have to delay getting the parents since it may require an application | ||
context. | ||
""" | ||
if not self._cached_parents: | ||
if callable(self._parents): | ||
self._cached_parents = self._parents() | ||
else: | ||
self._cached_parents = self._parents | ||
return self._cached_parents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tradeoff here was in favor of simplicity of "caching". The parents are computed once, so a restart of the application is needed if new subjects are installed. Maybe this can be documented somewhere, if so where?
@@ -303,3 +248,100 @@ def test_facets_post_filtering(app, service, identity_simple, records): | |||
# Test hits are filtered | |||
assert 1 == len(res) | |||
assert set(["001"]) == set([h["metadata"]["title"] for h in res]) | |||
|
|||
|
|||
def test_combined_terms_facets(app, service, identity_simple, search_clear): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test other combination of scheme+subject than in resource test to be thorough.
8a2d045
to
6624851
Compare
6624851
to
d389762
Compare
This approach doesn't use 'nested' fields, but instead relies on a field containing <parent><split char><child> to aggregate correctly.
d389762
to
1d370c4
Compare
the mergening has started |
This approach doesn't use 'nested' fields, but instead relies on a
field containing
<parent><split char><child>
to aggregate correctly.