Problem/Motivation
I'm not sure if this is a feature request or a support request.
I would like to create a fake / aggregated field in the index that will aggregate 2 different entity reference fields together.
So assuming the following data model:
Node Type: Report
Field: Report Topic (field_report_topic) entity reference to Topic node type
Node Type: Program
FIeld: Program Topic (field_program_topic) entity reference to Topic node type
Node Type: Topic
I would like to create a field in the search index that will apply to both Report and Program types, and will combine their 2 topic fields into one. This way, I can use one facet to filter both of them.
I have found examples of how to add an entity reference field via Processor here : https://git.drupalcode.org/project/search_api/-/blob/HEAD/tests/modules/...
This works well to add all the subfields of Topic to the index but it doesn't allow me to just create an integer field for the reference. I can chain in the nid of the Topic node but then I don't get the option to replace the ID with the node title when using a facet, because the field isn't recognized as an entity reference field.
I have tried adding a mapping from 'entity:node' to 'integer' in DataTypeHelper.php as brought up here :
https://www.drupal.org/project/search_api/issues/2732341 →
but that didn't seem to do anything other than remove 'entity_node' fields from the unmapped list. It doesn't allow an integer field to be added to the index that will be recognized by TranslateEntityProcessor facet as an entity reference.
I see that between a couple issues there might be a patch to get me closer:
https://www.drupal.org/project/search_api/issues/2858061
✨
Support for entity reference filtering like TaxonomyIndexTid
Postponed
https://www.drupal.org/project/search_api/issues/3253260
✨
Add an entity argument handler
Needs work
But it looks like they are still not ready or stale. I'm not quite sure what the referenced core issue is.
Any help appreciated here.