I have "linked" 2 content types (Type A and Type B) by a field using the entity reference module. They are "linked" by the other node's ID number. For example, the entity reference field would have an input that says: "Select the node ID which is related to this content". Now I would like to implement a smart search.

For example, if someone searches for Type A, the search should also return the content of Type B that is "linked" to Type A based on that entity reference field. Can this be done with search or Views? In quasi-SQL, it would be something like:

"SELECT * FROM TypeA, TypeB WHERE TypeA.field_A=TypeB.nid"

1 Answer 1


In Views this called "Relationships".

Create view that show "Type A", then in filters add "Type B" to be also allowed. Then add relation on field that you use for entity reference and made this relation required.

Now "Type B" content will be also displayed in view if related "Type A" is match search criteria.

  • This worked out nicely. However, there is a follow up where I have to display both content types from the results, but give one preference over the other and hide one type if a result is found, and unfortunately Views is not powerful enough to handle my requirements. :( Here is a good link on how to set Views relationships with entity reference: nodeone.se/sv/node/782
    – user785179
    Nov 13, 2012 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.