I want to add an indexed field to a Search API query in code. My query currently looks like this:
$index = search_api_index_load("default_node_index"); $query=new SearchApiQuery($index); $query->condition('type', 'answers_question', '='); $filter = $query->createFilter('OR'); $filter->condition('title', $text, '='); $filter->condition('body:value', $text, '='); $query->sort('search_api_relevance', DESC); $query->fields(array('title')); $query->filter($filter); $query->keys($text); $data=$query->execute();
This returns the correct results, however the result set is composed of an array of arrays with an 'id' and a 'score'. I want the indexed node title to be returned as well. I cannot do a join to the node table as ->join is not available on SearchApiQuery.
does not seem to do anything.
I have this same query set up in a view where it is working properly. When I inspect the query at hook_search_api_query_alter I cannot see where or how the title is added.
How do I add the indexed title as a field to be returned in the result set?