0

I'm trying to set up "best bets" in a Sitecore 9.3 environment.

I set up the Solr Query Elevation Component following the instructions at this URL: https://solr.apache.org/guide/6_6/the-query-elevation-component.html

It seems to work in Solr.

However, Sitecore won't honor that setting. When I search for a term I know we have results ("product X"), it doesn't appear at the top of the list like it should. Right now it's the 10th result. Based on what I set in the elevate.xml file, it should be the first result for the query "product X."

Is this component even supported? I don't see anything explicitly spelled out either way, but if anyone has successfully implemented it, how did you do it?

Do Sitecore configs need to change? How about the search code itself?

Elevate.xml file

<elevate>
  <query text="my query">
    <doc id="sitecore://master/{top result guid}?lang=en&amp;ampver=1&amp;ampndx=myindex_boosted" /> <!-- Product page -->
    <doc id="sitecore://master/{second result guid}?lang=en&amp;ampver=1&amp;ampndx=myindex_boosted" /> <!-- Product 2 -->
  </query>
</elevate>

Search log

8008 08:30:35 INFO  Warming and Caching your search indexes
8008 08:30:35 INFO  /******* Warming Queries ********/
8008 08:30:35 INFO  /*************************/
25112 08:31:13 INFO  Solr Query - ?q=((computedcontents_t:(*product*) OR _content:(*product*)) AND (computedcontents_t:(*name*) OR _content:(*name*)))&start=0&rows=10&fl=*,score&fq=(((-hidefromsearch_b:(True)  *:*) AND (-notinsearch_b:(True)  *:*)) AND _language:(en))&fq=_indexname:(my_index_index_boosted)&wt=xml
25112 08:31:14 INFO  Solr Query - ?q=__solr_norm_field_name_t:(_lastestversion)&start=0&rows=1&fq=_template:({template ID})&fq=_indexname:(my_index_index_boosted)&wt=xml
25112 08:31:14 INFO  Solr Query - ?q=__solr_norm_field_name_t:(_url)&start=0&rows=1&fq=_template:({template ID})&fq=_indexname:(my_index_index_boosted)&wt=xml
25112 08:31:14 INFO  Solr Query - ?q=((computedcontents_t:(*product*) OR _content:(*product*)) AND (computedcontents_t:(*name*) OR _content:(*name*)))&start=0&rows=5&fl=*,score&fq=((((computedtitle_t:("product name\*") AND _fullpath:(\/sitecore/content/product/home/products*)) AND (-hidefromsearch_b:(True)  *:*)) AND (-notinsearch_b:(True)  *:*)) AND _language:(en))&fq=_indexname:(my_index_index_boosted)&wt=xml
25112 08:31:14 INFO  Solr Query - ?q=__solr_norm_field_name_t:(_lastestversion)&start=0&rows=1&fq=_template:({template ID})&fq=_indexname:(my_index_index_boosted)&wt=xml
25112 08:31:14 INFO  Solr Query - ?q=__solr_norm_field_name_t:(_url)&start=0&rows=1&fq=_template:({template ID})&fq=_indexname:(my_index_index_boosted)&wt=xml
25112 08:31:14 INFO  Solr Query - ?q=((computedcontents_t:(*product*) OR _content:(*product*)) AND (computedcontents_t:(*name*) OR _content:(*name*)))&start=0&rows=1&fl=*,score&fq=((((computedtitle_t:("\*product name\*") AND _fullpath:(\/sitecore/content/product/home/trial*)) AND (-hidefromsearch_b:(True)  *:*)) AND (-notinsearch_b:(True)  *:*)) AND _language:(en))&fq=_indexname:(my_index_index_boosted)&wt=xml
25112 08:31:14 INFO  Solr Query - ?q=__solr_norm_field_name_t:(_lastestversion)&start=0&rows=1&fq=_template:({template ID})&fq=_indexname:(my_index_index_boosted)&wt=xml
25112 08:31:14 INFO  Solr Query - ?q=__solr_norm_field_name_t:(_url)&start=0&rows=1&fq=_template:({template ID})&fq=_indexname:(my_index_index_boosted)&wt=xml
5
  • Please can you include your modified Solr configs? It would be good to see your Sitecore-generated search query too, you can find it in the Search.log file.
    – Anna Gevel
    Dec 21, 2021 at 6:41
  • I've added the requested data - I think Solr is set up correctly (the core crashes when it's not). Do I need to modify the Linq query in some way? I've dug into the Sitecore docs but haven't found anything about this Solr component.
    – Tim
    Dec 21, 2021 at 13:37
  • 1
    Thanks Tim. By default the "elevator" search component is enabled only for the /elevate request handler. Sitecore uses the /query request handler so you may need to enable the "elevator" search component for it too. However, my biggest concern is Sitecore's format of the id field - it contains item version that can change easily.
    – Anna Gevel
    Dec 22, 2021 at 6:16
  • 1
    I suggest a slightly different approach that is natively supported by Sitecore. You can introduce a field for "Elevated keywords" on the product template. Then you can include the "Elevated keywords" in the search query and apply boosting to this part of the query. For example, the product page 1 will have "my query" in the "Elevated keywords" and your search query will look similar to: queryable.Where(x => x.ElevatedKeywords.Equals(keyword).Boost(boostFactor)).
    – Anna Gevel
    Dec 22, 2021 at 6:35
  • 1
    @AnnaGevel I had the same concern about the version but without it the query elevation doesn't work at all. Your suggestion for the elevated keywords sounds like it's a better fit, it would sure be easier to manage. I think that's the way to go at this point.
    – Tim
    Jan 5 at 16:54

1 Answer 1

1

I wound up using the approach recommended by @AnnaGevel and added a boosted keywords field. While I don't think this is quite as precise as the Query Elevation Component would be, it's maintainable by content editors without needing to write a custom add-on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.