Ambert
07/21/2023, 2:06 PMMultipleCharacterWildcard()
to my keyword, so it all searches properly. Great!
However, all items that have been returned, have the exact same score.
According to ChatGpt:
"When you perform a wildcard query, Lucene looks up the matching terms in the inverted index and retrieves the documents containing those terms. However, since wildcard queries are considered as exact matches, the relevance scoring for these documents might not differentiate between them effectively, leading to identical scores for all matches."
Now I'm quite sure other people have run in to this.. How did you work around this / fixed this?ProBot β¨
07/21/2023, 2:06 PMMaarten
07/21/2023, 2:11 PMMaarten
07/21/2023, 2:13 PMMaarten
07/21/2023, 2:14 PMD_Inventor
07/21/2023, 2:27 PMAmbert
07/21/2023, 2:41 PMMike Chambers
07/21/2023, 2:58 PMstring.Boost(float)
is in the examine string extensions using Examine
csharp
query.And().Group(n => n
.GroupedOr(new[] { "nodeName" }, keyword.Escape(), keyword.Boost(12))
.Or()
.GroupedOr(new[] { summaryAlias }, keyword.Escape(), keyword.Boost(10))
.Or()
.GroupedOr(new[] { descriptionAlias }, keyword.Escape(), keyword.Boost(8))
.Or()
.GroupedOr(new[] { authorityAlias }, keyword.Escape(), keyword.Boost(6))
.Or()
.GroupedOr(new[] { notesAlias }, keyword.Escape(), keyword.Boost(4))
.Or()
.GroupedOr(new[] { prerequisitesAlias }, keyword.Escape(), keyword.Boost(2))
.Or()
.GroupedOr(new[] { "nodeName", summaryAlias, descriptionAlias, authorityAlias, notesAlias, prerequisitesAlias }, keyword.Fuzzy())
.Or()
.GroupedOr(new[] { "nodeName", summaryAlias, descriptionAlias, authorityAlias, notesAlias, prerequisitesAlias }, keyword.MultipleCharacterWildcard())
);
D_Inventor
07/21/2023, 3:05 PMcsharp
if (search.Text is not null)
{
var terms = search.Text.Split(' ', StringSplitOptions.RemoveEmptyEntries);
query = query.And(sq =>
{
var boosted = terms.Select(t => t.Boost(5)).ToArray();
var fuzzy = terms.Select(t => t.Fuzzy(0.7f)).ToArray();
var wordTerms = boosted.Concat(fuzzy);
var op = sq.GroupedOr(new[] { Index.Defaults.IndexFieldNames.Word }, wordTerms.ToArray());
return op;
}, BooleanOperation.Or);
}
Ambert
07/21/2023, 5:27 PMAmbert
07/21/2023, 5:27 PMA hub and casual space for you to interact with fellow community members and learn more about Umbraco!
Powered by