Skip to content

Commit ee54e75

Browse files
hibnicokimchy
authored andcommitted
Add support for setting the boost to a text query in the Java client
1 parent ff90873 commit ee54e75

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/TextQueryBuilder.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public static enum Type {
5959

6060
private String analyzer;
6161

62+
private Float boost;
63+
6264
private Integer slop;
6365

6466
private String fuzziness;
@@ -100,6 +102,14 @@ public TextQueryBuilder analyzer(String analyzer) {
100102
return this;
101103
}
102104

105+
/**
106+
* Set the boost to apply to the query.
107+
*/
108+
public TextQueryBuilder boost(float boost) {
109+
this.boost = boost;
110+
return this;
111+
}
112+
103113
/**
104114
* Set the phrase slop if evaluated to a phrase query type.
105115
*/
@@ -139,6 +149,9 @@ public TextQueryBuilder maxExpansions(int maxExpansions) {
139149
if (analyzer != null) {
140150
builder.field("analyzer", analyzer);
141151
}
152+
if (boost != null) {
153+
builder.field("boost", boost);
154+
}
142155
if (slop != null) {
143156
builder.field("slop", slop);
144157
}

0 commit comments

Comments
 (0)