Java api: add missing boost support to TermsQueryBuilder
Relates to #11744 Closes #11810
This commit is contained in:
parent
e7702468a2
commit
90a7b4868e
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue