From 90a7b4868e1b16a682a9dc5e36d093b3d3aa0ef6 Mon Sep 17 00:00:00 2001 From: javanna Date: Mon, 22 Jun 2015 18:34:18 +0200 Subject: [PATCH] Java api: add missing boost support to TermsQueryBuilder Relates to #11744 Closes #11810 --- .../index/query/TermsQueryBuilder.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java index 63f9017ed8f..5cc13c7f6ff 100644 --- a/core/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java @@ -26,7 +26,7 @@ import java.io.IOException; /** * A filer for a field based on several terms matching on any of them. */ -public class TermsQueryBuilder extends QueryBuilder { +public class TermsQueryBuilder extends QueryBuilder implements BoostableQueryBuilder { private final String name; @@ -36,6 +36,8 @@ public class TermsQueryBuilder extends QueryBuilder { private String execution; + private float boost = -1; + /** * A filer for a field based on several terms matching on any of them. * @@ -131,6 +133,12 @@ public class TermsQueryBuilder extends QueryBuilder { return this; } + @Override + public TermsQueryBuilder boost(float boost) { + this.boost = boost; + return this; + } + @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(TermsQueryParser.NAME); @@ -140,6 +148,10 @@ public class TermsQueryBuilder extends QueryBuilder { builder.field("execution", execution); } + if (boost != -1) { + builder.field("boost", boost); + } + if (queryName != null) { builder.field("_name", queryName); }