0

We have a requirement wherein we need to make boosting for a field dynamic. Let's say that we have an indexed property foo, we need to perform a mathematical calculation on foo to determine its boost value which would be different for every product.

Is this doable in Hybris Solr?

Note: I'm using SAP CX 2105 and Solr 8.9.0 with Dismax Query Parse. And above requirement can be done in standalone Solr application as following.

@Resource
private SolrQuery solrQuery;

private void addBoosts()
{
    solrQuery.add("boost", "sub(20, sqrt(field(foo)))");
}

In Hybris, I have tried following

@Resource
private SearchQuery searchQuery;

private void addBoosts()
{
    searchQuery.addQuery("boost", "sub(20, sqrt(field(foo)))");
}

And also this

@Resource
private SearchQuery searchQuery;

private void addBoosts()
{
    searchQuery.addQuery("boost", "sub(20, sqrt(field(foo)))");
}

Both don't affect search order of the result.

Rupesh Vislawath
  • 125
  • 1
  • 11
  • Could you be more specific ? I think it amounts to using the eDisMax query parser’s [boost](https://solr.apache.org/guide/solr/latest/query-guide/edismax-query-parser.html#extended-dismax-parameters) parameter, eg. `{!boost b=log(foo)}term` creates a query "term" which is boosted by the function query `log(foo)` (each document matching "term" receives it's own multiplicative boost according to the value of log(foo)). Here you would just put the terms of the main query instead of "term". – EricLavault Jul 19 '22 at 16:59
  • Hi @EricLavault, Thanks for reply, I have added more details and context in question. – Rupesh Vislawath Jul 20 '22 at 11:30
  • I don't know if your code is doing properly what I suggest. The first step would be to tweak the query via [Solr Admin UI](https://solr.apache.org/guide/8_9/query-screen.html), by checking how boosting affects scoring (add 'score' to fl parameter and use debugQuery if necessary). Also, you mention the dismax query parser, but the `{!boost}` syntax works with **e**dismax only (see the checkboxes in Admin UI). Then once you got something suitable, you would implement it in your solr client. – EricLavault Jul 21 '22 at 13:04

0 Answers0