mikegoatly / lifti

A lightweight full text indexer for .NET
MIT License
184 stars 9 forks source link

Item score boosting #95

Closed mikegoatly closed 11 months ago

mikegoatly commented 11 months ago

Added magnitude and freshness score boosting #72

E.g.

Using freshness boosting to bump documents that have been most recently updated:

var index = new FullTextIndexBuilder<int>()
    .WithObjectTokenization<Document>(o => o
        .WithKey(d => d.Id)
        .WithField("Content", d => d.Content)
        // Boost the score of documents that have been updated most recently, multiplying the score on a range of 1 to 2 depending
        // the date of the document relative to the other documents.
        .WithScoreBoosting(o => o
            .Freshness(d => d.UpdatedDate, 2D)))
        .Build();

Magnitude boosting to bump documents with a higher rating:

var index = new FullTextIndexBuilder<int>()
    .WithObjectTokenization<Document>(o => o
        .WithKey(d => d.Id)
        .WithField("Content", d => d.Content)
        // Boost the score of documents with a higher rating multiplying the score on a range of 1 to 2 depending
        // on the rating.
        .WithScoreBoosting(o => o.Magnitude(d => d.Rating, 2D)))
    .Build();
mikegoatly commented 11 months ago

Lifting notes from comments:

Technically breaking

IdPool and IIdPool are now internal IItemStore new method Add used by deserializers Removed pointless interface IItemMetadata - just use ItemMetadata

Deprecated

ItemMetadata Item property -> use Key property instead ItemMetadata now has ScoringFreshnessData ItemMetadata now has ScoringMagnitude