Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Nov 30, 2023
1 parent 5dea9d2 commit b7d4bde
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ public static TextExpansionQueryBuilder fromXContent(XContentParser parser) thro
threshold = WeightedTokensThreshold.fromXContent(parser);
} else {
throw new ParsingException(
parser.getTokenLocation(),
"[" + NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"
parser.getTokenLocation(),
"[" + NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"
);
}
} else if (token.isValue()) {
Expand Down Expand Up @@ -288,12 +288,7 @@ public static TextExpansionQueryBuilder fromXContent(XContentParser parser) thro
throw new ParsingException(parser.getTokenLocation(), "No fieldname specified for query");
}

TextExpansionQueryBuilder queryBuilder = new TextExpansionQueryBuilder(
fieldName,
modelText,
modelId,
threshold
);
TextExpansionQueryBuilder queryBuilder = new TextExpansionQueryBuilder(fieldName, modelText, modelId, threshold);
queryBuilder.queryName(queryName);
queryBuilder.boost(boost);
return queryBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import static org.elasticsearch.xpack.ml.queries.WeightedTokensThreshold.TOKENS_THRESHOLD_FIELD;


public class WeightedTokensQueryBuilder extends AbstractQueryBuilder<WeightedTokensQueryBuilder> {
public static final String NAME = "weighted_tokens";

Expand Down Expand Up @@ -205,8 +204,8 @@ public static WeightedTokensQueryBuilder fromXContent(XContentParser parser) thr
} else if (TOKENS_THRESHOLD_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
if (token != XContentParser.Token.START_OBJECT) {
throw new ParsingException(
parser.getTokenLocation(),
"[" + TOKENS_THRESHOLD_FIELD.getPreferredName() + "] should be an object"
parser.getTokenLocation(),
"[" + TOKENS_THRESHOLD_FIELD.getPreferredName() + "] should be an object"
);
}
threshold = WeightedTokensThreshold.fromXContent(parser);
Expand Down Expand Up @@ -235,11 +234,7 @@ public static WeightedTokensQueryBuilder fromXContent(XContentParser parser) thr
throw new ParsingException(parser.getTokenLocation(), "No fieldname specified for query");
}

var qb = new WeightedTokensQueryBuilder(
fieldName,
tokens,
threshold
);
var qb = new WeightedTokensQueryBuilder(fieldName, tokens, threshold);
qb.queryName(queryName);
qb.boost(boost);
return qb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ public static WeightedTokensThreshold fromXContent(XContentParser parser) throws
onlyScorePrunedTokens = parser.booleanValue();
} else {
throw new ParsingException(
parser.getTokenLocation(),
"[" + TOKENS_THRESHOLD_FIELD.getPreferredName() + "] does not support [" + currentFieldName + "]"
parser.getTokenLocation(),
"[" + TOKENS_THRESHOLD_FIELD.getPreferredName() + "] does not support [" + currentFieldName + "]"
);
}
} else {
throw new ParsingException(
parser.getTokenLocation(),
"[" + TOKENS_THRESHOLD_FIELD.getPreferredName() + "] unknown token [" + token + "] after [" + currentFieldName + "]"
parser.getTokenLocation(),
"[" + TOKENS_THRESHOLD_FIELD.getPreferredName() + "] unknown token [" + token + "] after [" + currentFieldName + "]"
);
}
}
Expand Down

0 comments on commit b7d4bde

Please sign in to comment.