pub struct RandomScore { /* private fields */ }
Expand description
The random_score
generates scores that are uniformly distributed from 0
up to but not
including 1
.
By default, it uses the internal Lucene doc ids as a source of randomness, which is very efficient but unfortunately not reproducible since documents might be renumbered by merges.
In case you want scores to be reproducible, it is possible to provide a seed
and field
. The
final score will then be computed based on this seed, the minimum value of field
for the
considered document and a salt that is computed based on the index name and shard id so that
documents that have the same value but are stored in different indexes get different scores.
Note that documents that are within the same shard and have the same value for field
will
however get the same score, so it is usually desirable to use a field that has unique values
for all documents. A good default choice might be to use the _seq_no
field, whose only
drawback is that scores will change if the document is updated since update operations also
update the value of the _seq_no
field.
Implementations§
Source§impl RandomScore
impl RandomScore
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an instance of RandomScore
Sourcepub fn weight<T>(self, weight: T) -> Selfwhere
T: AsPrimitive<f32>,
pub fn weight<T>(self, weight: T) -> Selfwhere
T: AsPrimitive<f32>,
The weight
score allows you to multiply the score by the provided weight
. This can sometimes be desired
since boost value set on specific queries gets normalized, while for this score function it does not.
The number value is of type float.
Trait Implementations§
Source§impl Clone for RandomScore
impl Clone for RandomScore
Source§fn clone(&self) -> RandomScore
fn clone(&self) -> RandomScore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more