I apologize if this belongs in the search_api queue, but it seems it might be Solr related, so I'm posting it here in case.

As detailed in #1518484: Best mechanism to add custom fields to search index, I've written a search_api class to add a field containing the title of the workflow state to the Solr index to use in search results and as a facet. It is working fine as a facet (the facet block is created, and it works properly), but no value is returned in the search results. As shown in the attached screen shot, the data is indexed in the Solr index (also demonstrated by the fact that it's working as a facet), but even though it is available to be added as a field to a view (as Indexed Node: Workflow state), no results are returned in the search results for that field.

Here's my class:

class SearchAPIWorkflowStateAlterSettings extends SearchApiAbstractAlterCallback {

  public function alterItems(array &$items) {
    foreach ($items as $id => &$item) {
      // We have the sid for the workflow state, but for display purposes,
      // we need to convert it to the state name.
      if ($item->workflow != 0) {
        $state_object = workflow_get_workflow_states_by_sid($item->workflow);      
        // Assign value to search api variable.
        $item->search_api_workflow_state = $state_object->state;
      }
    }
  }
  
  public function propertyInfo() {
    return array(
      'search_api_workflow_state' => array(
        'label' => t('Workflow state'),
        'description' => t('The workflow state of the node.'),
        'type' => 'text',
      ),
    );
  }  
}

Is there anything else I'm missing to get this data to show in the search results?

Thanks.

CommentFileSizeAuthor
workflow_state_in_solr_index.jpg122.43 KBwonder95

Comments

OanaIlea’s picture

Status: Active » Closed (outdated)

This issue was closed due to lack of activity over a long period of time. If the issue is still acute for you, feel free to reopen it and describe the current state.