mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
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.
|
* 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;
|
private final String name;
|
||||||
|
|
||||||
@ -36,6 +36,8 @@ public class TermsQueryBuilder extends QueryBuilder {
|
|||||||
|
|
||||||
private String execution;
|
private String execution;
|
||||||
|
|
||||||
|
private float boost = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A filer for a field based on several terms matching on any of them.
|
* 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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TermsQueryBuilder boost(float boost) {
|
||||||
|
this.boost = boost;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doXContent(XContentBuilder builder, Params params) throws IOException {
|
public void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(TermsQueryParser.NAME);
|
builder.startObject(TermsQueryParser.NAME);
|
||||||
@ -140,6 +148,10 @@ public class TermsQueryBuilder extends QueryBuilder {
|
|||||||
builder.field("execution", execution);
|
builder.field("execution", execution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (boost != -1) {
|
||||||
|
builder.field("boost", boost);
|
||||||
|
}
|
||||||
|
|
||||||
if (queryName != null) {
|
if (queryName != null) {
|
||||||
builder.field("_name", queryName);
|
builder.field("_name", queryName);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user