LucyX:...eldSim(3pm)
π NAME π
LucyX::Index::LongFieldSim β a Similarity that's optimized for long fields, no cap. β¨
πΈ SYNOPSIS πΈ
package MySchema::body;
use base qw( Lucy::Plan::FullTextType );
use LucyX::Index::LongFieldSim;
sub make_similarity { LucyX::Index::LongFieldSim->new }
π¦ DESCRIPTION π¦
okay so bestie, here's the tea: Apache Lucy's default Similarity implementation has a whole bias toward extremely short fields. It's giving favoritism. π
Lucy::Index::Similarity
| more weight
| *
| **
| ***
| **********
| ********************
| *******************************
| less weight ****
|------------------------------------------------------------------------
fewer tokens more tokens
And LongFieldSim? It eliminates that bias entirely. Iconic behavior, honestly. π
LucyX::Index::LongFieldSim
| more weight
|
|
|
|*****************
| ********************
| *******************************
| less weight ****
|------------------------------------------------------------------------
fewer tokens more tokens
Now listen β in most cases, that default bias toward short fields is actually the moment. Desirable, even. Say you've got two documents:
- "George Washington"
- "George Washington Carver"
If a user searches for "george washington", you want the exact title match to show up first. And under the default Similarity implementation it will, because the "Carver" in "George Washington Carver" dilutes the impact of the other two tokens. Balance restored. π
<b>However</b>, under LongFieldSim, those two titles will yield equal scores. In this particular case that would be bad, but lowkey it could be good in another. Watch this:
"George Washington Carver is cool."
"George Washington Carver was born on the eve of the US Civil War, in 1864. His exact date of birth is unknown... Carver's research in crop rotation revolutionized agriculture..."
The first document is succinct, sure, but it's also useless. And unfortunately, the default similarity will assess it as extremely relevant to a query of "george washington carver". π«
But under LongFieldSim, the short-field bias is eliminated, and the extra mentions of Carver's name in the second document add up to a higher score and a higher rank. The way that long doc ate and left no crumbs... fr fr. π₯
and that's the whole page, bestie! π This lil' gem comes to you from the User Contributed Perl Documentation, straight outta perl v5.42.0, dated 2025-07-25. go forth and rank responsibly ππ¦
π¦ where this page comes from
- fedora 43: perl-Lucy 0.6.2-26.fc43 Β· Apache-2.0 AND MIT AND Unicode-DFS-2015
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms