Boosting without filtering in a SOLR subquery

180 views Asked by At

I have a SOLR query with some AND/OR filtering in it. This filtering is custom and is not that important in itself.

What I want to do, is adding a subquery to provide a booster value when the "_template" equals one of three values. I am trying to do this by adding a subquery, but the goal is to make sure that no additional filtering is done. I want to have the same result set, only with the booster values provided.

The reason that I'm doing this using a subquery and not using a Booster Query (bq) parameter, is that my query is actually generated using Sitecore's PredicateBuilder (from Sitecore.ContentSearch.Linq, version 6.0). The examples given below are SOLR queries, but this context is the reason why I want to solve it using a subquery.

Query 1 - original query

This is the original query. It's my starting point, so I want to take this query "as is". It gives 58 results.

?q=((((-_template:(86b04a1523f542b98561e5780328a2ff) *:*) AND (_name:(*searchterm*) OR _name:(searchterm) OR _name:(searchterm*) OR (_name:(*searchterm*))^20 OR (_name:(searchterm~0.8))^20 OR _content:(searchterm~0.8) OR _description_t:(searchterm~0.8) OR type_t:(searchterm~0.8) OR variant_t:(searchterm~0.8)))) )&start=0&rows=99&fl=_template,_title_t_nl,score&fq=_indexname:(customindex)&wt=xml

Query 2 - added a subquery

This is the original query, where I've added a subquery to match one of the three course template IDs and then give a boost value of 35. However, this query gives only 36 results (because all pages not having on the three given template IDs are completely filtered out.)

?q=((((-_template:(86b04a1523f542b98561e5780328a2ff) *:*) AND (_name:(*searchterm*) OR _name:(searchterm) OR _name:(searchterm*) OR (_name:(*searchterm*))^20 OR (_name:(searchterm~0.8))^20 OR _content:(searchterm~0.8) OR _description_t:(searchterm~0.8) OR type_t:(searchterm~0.8) OR variant_t:(searchterm~0.8)))) AND ((_template:(3aa541dcf9d3471ba5d79d397b3e793c))^35 OR (_template:(a2f633e201ab473ea3a9962106921d27))^35 OR (_template:(060412222e0a475a9b2c3adc9cb7fb2e))^35))&start=0&rows=99&fl=_template,_title_t_nl,score&fq=_indexname:(customindex)&wt=xml

Query 3 - tried to make the subquery only add booster values

In this query I've added the additional case of adding any templates which are not equal to all zeroes. My expectation was that this would have the effect that no results are filtered out anymore, but that the boosting would still be there.

However, for some reason, it still filters out the unknown templates and gives only 36 results.

?q=((((-_template:(86b04a1523f542b98561e5780328a2ff) *:*) AND (_name:(*searchterm*) OR _name:(searchterm) OR _name:(searchterm*) OR (_name:(*searchterm*))^20 OR (_name:(searchterm~0.8))^20 OR _content:(searchterm~0.8) OR _description_t:(searchterm~0.8) OR type_t:(searchterm~0.8) OR variant_t:(searchterm~0.8)))) AND ((_template:(3aa541dcf9d3471ba5d79d397b3e793c))^35 OR (_template:(a2f633e201ab473ea3a9962106921d27))^35 OR (_template:(060412222e0a475a9b2c3adc9cb7fb2e))^35 OR (-_template:(00000000000000000000000000000000))))&start=0&rows=99&fl=_template,_title_t_nl,score&fq=_indexname:(customindex)&wt=xml

The question is: why does the third query not work and how can I adjust it to make it work? I.e., how can I make it return all original 58 results, but with increased booster values for the provided template IDs?

0

There are 0 answers