We are using SOLR 6.6 and I just tried updating from search_api_solr 1.x to the new 2.0 branch.
In our hook_search_api_solr_query_alter() function we add several boosts using code like the following:
/** @var \Solarium\Component\EdisMax $edismax */
$edismax = $solarium_query->getEDisMax();
$boost_queries['ss_title_exact'] = [
'query' => "ss_title_exact:\"$query_value\"^11.0",
];
$edismax->addBoostQueries($boost_queries);
$boost_functions = 'recip(abs(ms(NOW/HOUR,ds_node_display_date)),3.16e-11,1,.4)^3';
$edismax->setBoostFunctions($boost_functions);
However, these no longer seem to work. I don't know if Solarium 4 has changed how this works, but the functions we are calling all still seem to be valid. But search_api_solr seems to completely these query changes now.
Is this a bug in the new search_api_solr or something I'm doing the wrong way? If so, how do I add boost functions in the new version?
Comments
Comment #2
mkalkbrennerWe don't run (e)dismax queries by default anymore because this query parser is restricted since Solr 7.2 and broke things like location searches.
But we tried keep the required changes minimal. See #2948469: Wrong usage of edismax causes fewer or no results on Solr 7.1 and earlier; Exceptions on Solr 7.2.
Try to add this to your alter hook:
Does that help?
Comment #3
mpotter commentedThanks! Yep, that did it (along with a couple ts_* -> tm>* field name changes).
Does this change need to be documented somewhere? Apologies if it already is and I missed it.
Comment #4
mkalkbrennerYou should leverage SolrBackendInterface::getSolrFieldNames() for that.
It seems that our documentation for devs isn't sufficient. Help is welcome ;-)
Comment #5
mkalkbrennerOK, here's at least some documentation.
Comment #7
mkalkbrennerComment #9
bdimaggioHey @mkalkbrenner, I just wanted to thank you for this incredibly helpful documentation. Your example just saved me a ton of work!