A basic guide to setting up a view for showing backreferences from node of Content Type A to Content Type B would be much appreciated.

Comments

rjacobs’s picture

The following seems to work (after this module is installed of course):

  1. In the search index settings make sure the fields that you want to reference through the back-reference are indexed. Also make sure "Backward reference to node via field_yourfieldname" is indexed for the entity reference that you want to use as a basis for your back-reference.
  2. Re-index
  3. In your view add a relationship of the type "Indexed Node: Backward reference to node via field_yourfieldname"
  4. Now you should be able to add fields to your view that use the back-reference, just like you can with the "Referencing Entity" relationship in a standard Entiry API setup (that uses the core DB). Finding which fields actually can use the relationship can be a bit tricky though, as they may be listed/labeled in multiple ways. The labels that seem to work are of the from "Node: Label" as opposed to "Indexed Node: Label".

That last point is one that could potentially used a bit of additional clarification/research. It's not totally clear to me to what extent the backreferenced field can be located and fetched directly from the Search API DB (like a true SQL join would do) without needing to do an entity_load() for the backreferenced entity. My thinking was that if the entity reference field and the target field were both indexed in the same Search API index then maybe it would be possible, but I have not investigated all this. This all seems to be pretty sticky... as shown in the conversations at:

#1130806: Potential Performance Issues
#1154116: Search API Solr retrieving search results data directly from SOLR, avoid going through MySQL
#1089758: Make use of new flexibility for Views field handlers

Someone else may be able to elaborate on all this a bit further....