$this->search_score =
$this->query->
addField('', "
$search_index.score *
$search_total.count", 'score',
['function' => 'sum'
]);
// Add the conditions set up by the search query to the views query.
$search_condition->
condition("
$search_index.type",
$this->searchType
);
$search_dataset =
$this->query->
addTable('node_search_dataset'
);
$conditions =
$this->searchQuery->
conditions();
$condition_conditions =&
$conditions->
conditions();
foreach ($condition_conditions as $key => &
$condition) { // Make sure we just look at real conditions.
if (is_numeric($key)) { // Replace the conditions with the table alias of views.
$this->searchQuery->
conditionReplaceString('d.', "
$search_dataset.",
$condition);
} } $search_conditions =&
$search_condition->
conditions();
$search_conditions =
array_merge($search_conditions,
$condition_conditions);
// Add the keyword conditions, as is done in
// SearchQuery::prepareAndNormalize(), but simplified because we are
// only concerned with relevance ranking so we do not need to normalize.
$or =
$this->view->query->
getConnection()->
condition('OR'
);
foreach ($words as $word) { $or->
condition("
$search_index.word",
$word);
}