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?

CommentFileSizeAuthor
#5 2979164.patch2.54 KBmkalkbrenner

Comments

mpotter created an issue. See original summary.

mkalkbrenner’s picture

We 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:

$solarium_query->addParam('defType', 'edismax');

Does that help?

mpotter’s picture

Status: Active » Closed (works as designed)

Thanks! 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.

mkalkbrenner’s picture

Status: Closed (works as designed) » Fixed

along with a couple ts_* -> tm>* field name changes

You should leverage SolrBackendInterface::getSolrFieldNames() for that.

It seems that our documentation for devs isn't sufficient. Help is welcome ;-)

mkalkbrenner’s picture

Title: Cannot alter solarium edismax query in Alter hook » Document how to alter a solarium edismax query in a hook
Component: Code » Documentation
Category: Support request » Feature request
Status: Fixed » Needs review
StatusFileSize
new2.54 KB

OK, here's at least some documentation.

  • mkalkbrenner committed c8fa526 on 8.x-2.x
    Issue #2979164 by mkalkbrenner: Document how to alter a solarium edismax...
mkalkbrenner’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bdimaggio’s picture

Hey @mkalkbrenner, I just wanted to thank you for this incredibly helpful documentation. Your example just saved me a ton of work!