Adding a field to a content type for Apache Solr search and Facets I've got a content type of Journal, and another content type of Article. All of the data associated with the Journal itself is stored on that content type, and not duplicated in the Article; the Article just has an entity reference to the Journal. So, for instance, Journal has a Year field, but Article has no Year field. (Conceptually, a Journal is a collection of Articles.)

For the most part, this entity reference relationship works great (and avoids duplicate information.) However, when doing things like searching, it can have some side effects. For example, if someone searches for a keyword, gets back a list of Articles with that keyword, they're then not able to filter that down by Year using facets, since that content type doesn't technically have a year associated with it, just a reference to a different content type that does. I'm hoping to find a way around that, but I'm not sure how to get it working.

I'm still pretty confused on the relationship between the Solr server we have and the Drupal site. It was my idea that once all was indexed, the Solr server takes the search string, and just ships back nodes/entities/etc. that match. If that's wrong or right, I'm still not sure if my problem has to do with Solr or FacetAPI.

What I've done so far is below, but it seems to have no effect on the search results. (In other words, if I search for a year, the articles aren't being returned as results; I'm not even worrying about Facets yet, even though those are the ultimate goal.)

function issue_archive_apachesolr_index_document_build_node(ApacheSolrDocument $document, $node, $env_id){
  if($node-&gt;type == "article") {
    // Load the journal this article is associated with, and get it's year
    // The is_ prefix is to denote a single (instead of multi-value) integer
    $journal = node_load($node-&gt;field_journal['und'][0]['target_id']);
    $document-&gt;setField('is_article_year', intval($journal-&gt;field_year['und'][0]['value']));
  }
}

function issue_archive_apachesolr_query_prepare(DrupalSolrQueryInterface $query) {
  // Make the indexed fields available for search results
  $query-&gt;addParam('fl', 'is_article_year');
  // Filter where 'index_field_name' = 'indexed_value'
  $query-&gt;addFilter('is_article_year', 'indexed_value');
}
Figured it out. Adding the answer in case anyone else needs it. Code below...

function issue_archive_apachesolr_index_document_build_node(ApacheSolrDocument $document, $node, $env_id) {
  if($node-&gt;type == "article") {
    $node = node_load($node-&gt;nid);
    $journal = node_load($node-&gt;field_journal['und'][0]['target_id']);
    $document-&gt;addField('its_field_year', $journal-&gt;field_year['und'][0]['value'] + 0);
    $document-&gt;addField('itm_field_year', $journal-&gt;field_year['und'][0]['value'] + 0);
  }
}

function issue_archive_apachesolr_query_prepare(DrupalSolrQueryInterface $query) {
  $query-&gt;addParam('qf', 'its_field_year');
  $query-&gt;addParam('qf', 'itm_field_year');
}


Using the solr_devel module, I saw that the journal type had two fields listed in the entity/document for year, one with the its_ prefix, and the other with the itm_prefix. I added both of those, and added the query field (I think that's what it stands for?) parameters to the query.

This got me the exact results I was looking for.