Struct elasticsearch_dsl::search::queries::specialized::DistanceFeatureQuery [−][src]
pub struct DistanceFeatureQuery<O: Origin> { /* fields omitted */ }
Expand description
Boosts the relevance score
of documents closer to a provided origin
date or point.
For example, you can use this query to give more weight to documents
closer to a certain date or location.
You can use the distance_feature
query to find the nearest neighbors to a location.
You can also use the query in a bool
search’s should
filter to add boosted relevance scores to the bool
query’s scores.
How the distance_feature
query calculates relevance scores
The distance_feature
query dynamically calculates the distance between the
origin
value and a document’s field values. It then uses this distance as a
feature to boost the
relevance-scores
of closer documents.
The distance_feature
query calculates a document’s
relevance score
as follows:
relevance score = boost * pivot / (pivot + distance)
The distance
is the absolute difference between the origin
value and a
document’s field value.
Skip non-competitive hits
Unlike the
function_score
query or other ways to change
relevance scores
, the distance_feature
query efficiently skips non-competitive hits when the
track_total_hits
parameter is not true
.
To create distance feature query date query:
Query::distance_feature("test", Utc.ymd(2014, 7, 8).and_hms(9, 1, 0), Time::Days(7))
.boost(1.5)
.name("test");
To create distance feature query geo query:
Query::distance_feature("test", GeoPoint::coordinates(12.0, 13.0), Distance::Kilometers(15))
.boost(1.5)
.name("test");
Distance Feature is built to allow only valid origin and pivot values, the following won’t compile:
Query::distance_feature("test", Utc.ymd(2014, 7, 8).and_hms(9, 1, 0), Distance::Kilometers(15))
.boost(1.5)
.name("test");
Implementations
Floating point number used to decrease or increase the
relevance scores
of a query. Defaults to 1.0
.
You can use the boost parameter to adjust relevance scores for searches containing two or more queries.
Boost values are relative to the default value of 1.0
.
A boost value between 0 and 1.0
decreases the relevance score.
A value greater than 1.0
increases the relevance score.
You can use named queries to track which queries matched
returned documents. If named queries are used, the response
includes a matched_queries
property for each hit.
Trait Implementations
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl<O> RefUnwindSafe for DistanceFeatureQuery<O> where
O: RefUnwindSafe,
<O as Origin>::Pivot: RefUnwindSafe,
impl<O> Send for DistanceFeatureQuery<O> where
O: Send,
<O as Origin>::Pivot: Send,
impl<O> Sync for DistanceFeatureQuery<O> where
O: Sync,
<O as Origin>::Pivot: Sync,
impl<O> Unpin for DistanceFeatureQuery<O> where
O: Unpin,
<O as Origin>::Pivot: Unpin,
impl<O> UnwindSafe for DistanceFeatureQuery<O> where
O: UnwindSafe,
<O as Origin>::Pivot: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more