Java api: add missing boost support to TermsQueryBuilder

Relates to #11744
Closes #11810
This commit is contained in:
javanna 2015-06-22 18:34:18 +02:00 committed by Luca Cavanna
parent e7702468a2
commit 90a7b4868e
1 changed files with 13 additions and 1 deletions

View File

@ -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<TermsQueryBuilder> {
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);
}