Skip to content

Commit 2ef12c3

Browse files
author
Christoph Büscher
committed
Add builder for distance_feature to QueryBuilders (#47846)
The QueryBuilders convenience class is currently missing a shortcut to construct a DistanceFeatureQueryBuilder, which is added here. Closes #47767
1 parent 5cbc96c commit 2ef12c3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

server/src/main/java/org/elasticsearch/index/query/QueryBuilders.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.common.geo.ShapeRelation;
2626
import org.elasticsearch.common.geo.builders.ShapeBuilder;
2727
import org.elasticsearch.geometry.Geometry;
28+
import org.elasticsearch.index.query.DistanceFeatureQueryBuilder.Origin;
2829
import org.elasticsearch.index.query.MoreLikeThisQueryBuilder.Item;
2930
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
3031
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder;
@@ -113,6 +114,16 @@ public static DisMaxQueryBuilder disMaxQuery() {
113114
return new DisMaxQueryBuilder();
114115
}
115116

117+
/**
118+
* A query to boost scores based on their proximity to the given origin for date, date_nanos and geo_point field types.
119+
* @param name The field name
120+
* @param origin The origin of the distance calculation. Can be a long, string or {@link GeoPoint}, depending on field type.
121+
* @param pivot The distance from the origin at which relevance scores receive half of the boost value.
122+
*/
123+
public static DistanceFeatureQueryBuilder distanceFeatureQuery(String name, Origin origin, String pivot) {
124+
return new DistanceFeatureQueryBuilder(name, origin, pivot);
125+
}
126+
116127
/**
117128
* Constructs a query that will match only specific ids within all types.
118129
*/

0 commit comments

Comments
 (0)