I am not sure if this is an issue or if I am not understanding how to utilize this correctly. I am trying to utilize the Search API with a multi-level hierarchical taxonomy. I am then trying to utilize Views to display the taxonomy correctly in the hierarchical order intended.

- Index is added for Entity type taxonomy with solr server (have search_api_solr as well)
- Taxonomy terms and Parent terms are indexed as strings down to the appropriate level to catch all levels
- Under Workflow, I enabled Aggregated fields,
- Under Workflow - Callback Settings - Aggregated fields, I added a New field with Fulltext aggregation type and added Name and Parent Term >> Name
- The field successfully appears in the Fields area -- I enabled it as a string and reindexed. Everything looks hunky dory

The field appears as an option in Views. Yay! When I add Name as an individual field, it shows up in my view. When I add Parent Term >> Name in my view, it shows up. However, when I add my aggregated field, which is supposed to include both terms, the column shows up, but it is empty -- nothing there.

What am I missing?

Comments

drunken monkey’s picture

Ah, that's an oversight on my part. Aggregated fields (and others added by data alterations) shouldn't be listed as possible Views fields, as data alterations are only called at indexing time, not on the search results. Therefore, those fields aren't available for search results, which is necessary (or, at least, reasonable) since some data alterations need quite some time (e.g., for parsing attachments).
The attached patch removes those field handlers.

For your use case, however, it seems to me the easiest solution would be to just display both "Name" and "Parent Term: Name", and concatenate them in the output (in a way depending on the Views display style).

drunken monkey’s picture

Status: Active » Needs review
magibird’s picture

Yes, the option to "display both "Name" and "Parent Term: Name", and concatenate them in the output (in a way depending on the Views display style)" works ALMOST perfectly, except I cannot sort by the Parent Term: Name. If I could use the parent terms in sorting, I believe this would be almost perfect. Is there any possibility that the the Parent Term: Name, and of course the Parent Term >> Parent Term >> Name (etc.) options could be sortable fields?

drunken monkey’s picture

Is there any possibility that the the Parent Term: Name, and of course the Parent Term >> Parent Term >> Name (etc.) options could be sortable fields?

No, not really. Parent terms are multi-valued, therefore all their fields will also be multi-valued internally in the Search API. And sorting on multi-valued fields is not supported, for obvious reasons.

drunken monkey’s picture

Status: Needs review » Fixed

I hope the support request is cleared up, anything else would be a feature request.
The issue with the fields added by a data alteration being listed in the available fields (which the patch in #1 is for) will automatically be fixed with #1064884: Add support for indexing non-entities.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.