Explorar o código

Java api: add missing boost support to GeoShapeQueryBuilder

Relates to #11744
Relates to #11810
javanna %!s(int64=10) %!d(string=hai) anos
pai
achega
e7702468a2

+ 13 - 1
core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java

@@ -29,7 +29,7 @@ import java.io.IOException;
 /**
  * {@link QueryBuilder} that builds a GeoShape Filter
  */
-public class GeoShapeQueryBuilder extends QueryBuilder {
+public class GeoShapeQueryBuilder extends QueryBuilder implements BoostableQueryBuilder<GeoShapeQueryBuilder> {
 
     private final String name;
 
@@ -46,6 +46,8 @@ public class GeoShapeQueryBuilder extends QueryBuilder {
     private String indexedShapePath;
 
     private ShapeRelation relation = null;
+
+    private float boost = -1;
     
     /**
      * Creates a new GeoShapeQueryBuilder whose Filter will be against the
@@ -146,6 +148,12 @@ public class GeoShapeQueryBuilder extends QueryBuilder {
         return this;
     }
 
+    @Override
+    public GeoShapeQueryBuilder boost(float boost) {
+        this.boost = boost;
+        return this;
+    }
+
     @Override
     protected void doXContent(XContentBuilder builder, Params params) throws IOException {
         builder.startObject(GeoShapeQueryParser.NAME);
@@ -177,6 +185,10 @@ public class GeoShapeQueryBuilder extends QueryBuilder {
 
         builder.endObject();
 
+        if (boost != -1) {
+            builder.field("boost", boost);
+        }
+
         if (name != null) {
             builder.field("_name", queryName);
         }