2

Drupal 7 Modules: Facet_api 7.x-1.3 Search_api 7.x-1.6 Relation 7.x-1.0-rc4

My site has two nodes, node one provides a description of various astronomical objects and node two are images and their composition details. I’ve built a many to many relationship between the two nodes and there is a node index (search_api) which contains all fields from the two content types with facets enabled on the primary fields.

I’ve created the faceted search page for the Astronomical objects which works fine and I now want to extend the Astronomical facets to gallery search page (. e.g. Show all images containing an astronomical object of type galaxy) which is where I have become stuck as I can’t see a way to create an index which joins relationships and nodes.

If this approach isn’t possible the only alternative I can think of is building out the relation type with extra fields duplicating the data that I want from either node and building the index on it, which just feels like a hack. Any suggestions?

2 Answers 2

1

At the bottom of the fields page you can see additional fields. This allows you to join nodes via relationships.

Search API > Default index > Fields > [Scroll to bottom} > Add related fields

  1. Select your field that is an entity reference.
  2. You'll have access to the fields of the reference too.
  3. Then select the fields on the referenced node that you need and save.
  4. And return to facets.

http://example.com/admin/config/search/search_api/index/default_node_index/fields#edit-additional

1

I can't post comments, so excuse me, but I think that I should warn you about one moment. The first answer is right for me, but you must remember that if related field was changed - you must manually rebuild index. I found one solution: use hook and

search_api_track_item_change($entity_target, $entity_ids);

search_api_track_item_change

hook_node_insert

Another way is to rebuild index via cron.

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.