lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Itamar Syn-Hershko <>
Subject Re: Weighting results by 'freshness'
Date Fri, 05 May 2017 10:19:10 GMT
2 notes on this:

1. You can use the date as a tie breaker as a second or third sort order.
See for instance

2. In 4.8 there is something new called FunctionQuery - if you store dates
as numerics you get to execute a function on the score and document values
during search. I will try to find some time to add a working example of
this to



Itamar Syn-Hershko
Freelance Developer & Consultant
Elasticsearch Partner
Microsoft MVP | Lucene.NET PMC | @synhershko <>

On Thu, Apr 6, 2017 at 1:26 AM, <>

> Hi Michael,
> I’d do it by storing the datestamp as a numeric field at the desired
> resolution, and then writing a scorer which calculates ‘age’ of a document
> (‘now’ minus the datestamp) and *reducing* the document’s score (multiply
> by weighting less than 1) based on that. Something like (x/(x+age))^n
> should work, with x and n adjustable for the desired falloff
> characteristics.
> Mapping DateTimeOffset->integer in a stable fashion is usually awkward
> because future calendar changes can break stored data, but since we’re only
> dealing with past dates here it should be simple. You could probably get
> away with using Ticks, which is at least evenly distributed across past
> times.
> Alex Davidson
> Bluewire Technologies
> From: Michael Newton
> Sent: 05 April 2017 18:39
> To:
> Subject: Weighting results by 'freshness'
> Hi,
> I've managed to build a nice little back end with 4.0.8 and the
> free text side of things is working really well. However, I'd like to add a
> weighting to the queries supplied that means that newer documents are
> considered more highly (but not to outright sort by date).
> I have a "created" field on all of my documents, which has been populated
> using "DateTools.DateToString" with a resolution of day, but I'm uncertain
> how to add a query which add weight to results based on "the higher the
> value of field 'x', the better".
> What would be the best way to go about this?
> My current query code (in F#) looks like this:
>     let parser =
>         QueryParsers.Classic.MultiFieldQueryParser
>             (Util.LuceneVersion.LUCENE_48, [| "title"; "content" |],
>              context.Analyzer)
>     let query = parser.Parse phrase
> Many thanks,
> Michael

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message