There's a section in apachesolr_do_query()
that removes fq
params, and moves them into a q.alt
statement, if certain conditions match.
$keys = $query->getParam('q');
if (strlen($keys) == 0 && ($filters = $query->getFilters())) {
// Move the fq params to q.alt for better performance. Only suitable
// when using dismax or edismax, so we keep this out of the query class itself
// for now.
$qalt = array();
foreach ($filters as $delta => $filter) {
// Move the fq param if it has no local params and is not negative.
if (!$filter['#exclude'] && !$filter['#local']) {
$qalt[] = '(' . $query->makeFilterQuery($filter) . ')';
$query->removeFilter($filter['#name'], $filter['#value'], $filter['#exclude']);
}
}
if ($qalt) {
$query->addParam('q.alt', implode(' ', $qalt));
}
}
When it comes to scoring and boost biasing, fq
and q.alt
are treated differently: filters in fq
do not contribute to the score of retrieved documents, whilst filters in q.alt
do. For example, if the filter was "color=red OR color=blue", and red comprised 1% of the total documents whilst blue comprised 10% of the total documents, the filter would give a higher score to red documents if it were set using q.alt
. If you wanted the filters to behave neutrally, and bias the results in a different way using a custom boost function, then the filter conditions must stay as fq
.
This patch adds an additional clause, so that developers can disable the performance-optimization via an environment variable.
Comment | File | Size | Author |
---|---|---|---|
#1 | apachesolr-2140041-1.patch | 803 bytes | manarth |
Comments
Comment #1
manarth CreditAttribution: manarth commentedComment #2
Nick_vhThe setting might be a little too global. Perhaps with a more detailed configuration variable? Also, I'd like to test this out similar to this example: #2157535: 40x Bias multiplier on content / custom fields so setting to needs work