0

I've got some code that's generating a predicate for Solr search as follows:

foreach (string query in querySplit) {
  contentPredicate = contentPredicate.Or(item => item.DocumentTitle.Matches(query)).Boost(10.0f);
  contentPredicate = contentPredicate.Or(item => item.Body.Matches(query).Boost(5.0f));
}

When I look at the query that results from this in the log, I see the following:

70460 10:47:13 INFO  Solr Query - ?q=((((alltemplates_sm:(72220db715134422bcd8e74fdbb0a900) AND (-_name:("__Standard Values")  *:*)) AND (-_name:($name)  *:*)) AND (document_title_t:/advisory/ OR (body_t:/advisory/)^5))&start=0&rows=10&fq=_indexname:(sitecore_master_index)

So I see the boost on the Body field, but not on the DocumentTitle field. I've tried a lower boost value on DocumentTitle, but it's not picking it up in any circumstance. DocumentTitle is a single-line text field, and Body is a rich text field. These are using the out-of-box definitions for the fields, no computed fields. Why would the boost not be applied to certain fields?

2
  • It looks like your parenthesis need to be fixed. Try contentPredicate = contentPredicate.Or(item => item.DocumentTitle.Matches(query).Boost(10.0f)). Commented Mar 9, 2020 at 14:20
  • @AlessandroFaniuolo That looks like it was the answer. Can you provide that as the answer (instead of a comment) so I can credit you? Commented Mar 10, 2020 at 23:43

1 Answer 1

2

It looks like your parenthesis need to be fixed.

Try contentPredicate = contentPredicate.Or(item => item.DocumentTitle.Matches(query).Boost(10.0f)) instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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