- last update
over 1 year ago 534 pass - 🇳🇱Netherlands kingdutch
Since the functionality that I needed and that Drunken Monkey describes in #13 without the per-subfield configuration already works as per #12 I've written an update for the hierarchy processor.
The attached patch is a fresh rewrite and updates
AddHierarchy
to also look at the subfields of any aggregated fields. If those subfields can all be put into a hierarchy of the same type, then the aggregated field is added as an option with that type under the processor settings. This allows the normal form save functionality to kick in and update the configuration which leads to the scenario of #12 where everything else already just works (TM).I'm not sure whether this is acceptable as-is or needs tests specifically for hierarchies of aggregated fields?
- 🇦🇹Austria drunken monkey Vienna, Austria
Looks great, thanks a lot! This seems like a much simpler solution. Would be great if others could give it a try.
Just some minor nit-picks, fixed in the attached revision:
-
+++ b/src/Plugin/search_api/processor/AddHierarchy.php @@ -123,28 +124,80 @@ + [$datasource_id, $path] = Utility::splitCombinedId($aggregated_field); + if ($datasource_id === NULL) { + continue 2; + }
I don’t think this check is needed here. In theory, I think, it shouldn’t be a problem to aggregate datasource-independent fields, and they could (theoretically) also reference taxonomy terms (or other hierarchical fields).
Or did you run into some specific problem without this? -
+++ b/src/Plugin/search_api/processor/AddHierarchy.php @@ -123,28 +124,80 @@ + $aggregated_type ??= $type;
Thanks a lot, didn’t know about that operator!
However, we (nominally) still support PHP 7.3 (even though this should soon change), so we probably should use the long version.
And yes, it would be great if you could also add a test for this new functionality. There is specific code for it, so it should be covered by tests.
-
- last update
over 1 year ago 534 pass - Status changed to Needs work
over 1 year ago 5:57am 7 May 2023