|
32 | 32 | * Query to run on a [rank_feature] field.
|
33 | 33 | */
|
34 | 34 | public final class RankFeatureQueryBuilder extends AbstractQueryBuilder<RankFeatureQueryBuilder> {
|
| 35 | + private static final ScoreFunction DEFAULT_SCORE_FUNCTION = new ScoreFunction.Saturation(); |
35 | 36 |
|
36 | 37 | /**
|
37 | 38 | * Scoring function for a [rank_feature] field.
|
@@ -309,7 +310,7 @@ private static ScoreFunction readScoreFunction(StreamInput in) throws IOExceptio
|
309 | 310 | if (numNonNulls > 1) {
|
310 | 311 | throw new IllegalArgumentException("Can only specify one of [log], [saturation], [sigmoid] and [linear]");
|
311 | 312 | } else if (numNonNulls == 0) {
|
312 |
| - query = new RankFeatureQueryBuilder(field, new ScoreFunction.Saturation()); |
| 313 | + query = new RankFeatureQueryBuilder(field, DEFAULT_SCORE_FUNCTION); |
313 | 314 | } else {
|
314 | 315 | ScoreFunction scoreFunction = (ScoreFunction) Arrays.stream(args, 3, args.length).filter(Objects::nonNull).findAny().get();
|
315 | 316 | query = new RankFeatureQueryBuilder(field, scoreFunction);
|
@@ -368,8 +369,10 @@ protected void doWriteTo(StreamOutput out) throws IOException {
|
368 | 369 | protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
369 | 370 | builder.startObject(getName());
|
370 | 371 | builder.field("field", field);
|
371 |
| - scoreFunction.doXContent(builder); |
372 |
| - printBoostAndQueryName(builder); |
| 372 | + if (false == scoreFunction.equals(DEFAULT_SCORE_FUNCTION)) { |
| 373 | + scoreFunction.doXContent(builder); |
| 374 | + } |
| 375 | + boostAndQueryNameToXContent(builder); |
373 | 376 | builder.endObject();
|
374 | 377 | }
|
375 | 378 |
|
|
0 commit comments