Skip to content

Commit 0d745c4

Browse files
author
Christoph Büscher
committed
Add builder for distance_feature to QueryBuilders
The QueryBuilders convenience class is currently missing a shortcut to construct a DistanceFeatureQueryBuilder, which is added here. Closes elastic#47767
1 parent 2783432 commit 0d745c4

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

+11
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;
@@ -100,6 +101,16 @@ public static DisMaxQueryBuilder disMaxQuery() {
100101
return new DisMaxQueryBuilder();
101102
}
102103

104+
/**
105+
* A query to boost scores based on their proximity to the given origin for date, date_nanos and geo_point field types.
106+
* @param name The field name
107+
* @param origin The origin of the distance calculation. Can be a long, string or {@link GeoPoint}, depending on field type.
108+
* @param pivot The distance from the origin at which relevance scores receive half of the boost value.
109+
*/
110+
public static DistanceFeatureQueryBuilder distanceFeatureQuery(String name, Origin origin, String pivot) {
111+
return new DistanceFeatureQueryBuilder(name, origin, pivot);
112+
}
113+
103114
/**
104115
* Constructs a query that will match only specific ids within all types.
105116
*/

0 commit comments

Comments
 (0)